Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES module error on Node.js 13

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

riccardogioratocommented, Jan 24, 2020

I solved this issue by running node v12.0.0

mramatocommented, Mar 11, 2020

@AlexPiro there’s a PR into Cesium to fix this that should go out with it’s next release: (April 1)

We just need to do some additional review/testing on it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found