Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 12.13.1 - "require() of ES modules is not supported" from support-fetch-mock.js #481

Closed
fruitraccoon opened this issue Dec 11, 2019 · 3 comments · Fixed by #482
Closed

Comments

@fruitraccoon
Copy link

After updating node from version 12.13.0 to 12.13.1, I'm seeing the warning below when running npm ci:

> fetch-mock@8.0.1 postinstall C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock
> node scripts/support-fetch-mock.js

(node:24100) Warning: require() of ES modules is not supported.
require() of C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock\scripts\support-fetch-mock.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename support-fetch-mock.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock\package.json.

This is from this Node change. Unfortunately it is causing our build to fail on our CI server.

Reproduction steps:

  • Update node to version 12.13.1 (currently the latest LTS version)
  • In an empty folder run npm init and accept all default values
  • Run npm install fetch-mock

The warning above should be displayed.

Do any of the fixes suggested in the warning sound like they're a good fit for the project? (renaming the file to .cjs sounds the simplest to me)

@wheresrhys
Copy link
Owner

I'm gonna remove that script now. Thanks for reporting

@wheresrhys
Copy link
Owner

v8.0.2

@XhmikosR
Copy link

@wheresrhys doesn't seem to fix the issue :/

(node:2528) Warning: require() of ES modules is not supported.
require() of C:\Users\xmr\Desktop\web\node_modules\fetch-mock\scripts\support-fetch-mock.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename support-fetch-mock.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\xmr\Desktop\web\node_modules\fetch-mock\package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants