ES module error on Node.js 13
See original GitHub issueWhen running the tests using node v13.3.0 the following error is thrown.
Warning: require() of ES modules is not supported.
require() of /Users/tylerlindberg/repos/forks/gltf-pipeline/node_modules/cesium/index.js from /Users/tylerlindberg/repos/forks/gltf-pipeline/gulpfile.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/tylerlindberg/repos/forks/gltf-pipeline/node_modules/cesium/package.json.
It seems like an error due to Cesium’s recent upgrade to using ES6 modules in v1.63, as manually setting the package to v1.62.0 causes the tests to run successfully.
In Node versions 12 and below this error doesn’t occur
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and export...
Read more >Using ES modules in Node.js
To be able to load an ES module, we need to set “type”: “module” in this file or, as an alternative, we can...
Read more >CommonJS vs ES Modules in Node.js
NodeJS allows us to import CommonJS modules from ES Modules, since in this case, module. exports simply become the default export which we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved this issue by running node v12.0.0
@AlexPiro there’s a PR into Cesium to fix this that should go out with it’s next release: https://github.com/CesiumGS/cesium/pull/8659 (April 1)
We just need to do some additional review/testing on it.