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

ES module error on Node.js 13 #507

Closed
TyLindberg opened this issue Dec 8, 2019 · 10 comments · Fixed by #534
Closed

ES module error on Node.js 13 #507

TyLindberg opened this issue Dec 8, 2019 · 10 comments · Fixed by #534

Comments

@TyLindberg
Copy link

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

@lilleyse
Copy link
Contributor

Looks like the same issue in obj2gltf which also includes cesium - CesiumGS/obj2gltf#225.

@mramato do you know the best way to fix this?

@mramato
Copy link
Contributor

mramato commented Dec 10, 2019

This actually looks like a breaking change introduced in Node 13, everything works on 10 and 12. I'll have to do a little research to figure out the right path forward. @lilleyse can you write up an issue in Cesium about Node 13 support and link the other two issues? Tag it next release so we get it into Jan 2nd.

@lilleyse
Copy link
Contributor

Here's the cesium issue: CesiumGS/cesium#8452

@md2perpe
Copy link

I get this warning also in node v12.13.1:

node version: v12.13.1
(node:99307) Warning: require() of ES modules is not supported.
require() of /home/ingrid/PostProcessing/production/20200123T193215/node_modules/cesium/index.js from /home/ingrid/PostProcessing/production/20200123T193215/node_modules/gltf-pipeline/bin/gltf-pipeline.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 /home/ingrid/PostProcessing/production/20200123T193215/node_modules/cesium/package.json.

@riccardogiorato
Copy link

I solved this issue by running node v12.0.0

@AlexPiro
Copy link

Do anyone worked on this problem ? Changing node version of the project is not a solution ! As noticed by @md2perpe the problem also exists in some version of Node v12 so it is not v13 only related.

@mramato
Copy link
Contributor

mramato commented Mar 11, 2020

@AlexPiro there's a PR into Cesium to fix this that should go out with it's next release: CesiumGS/cesium#8659 (April 1)

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

@edsilv
Copy link

edsilv commented Mar 27, 2020

If I try converting a glb to draco using node v12.0.0 I get Error: Cannot find module './freezeObject.js'

@lilleyse
Copy link
Contributor

@edsilv you might need to run npm install to get the latest cesium version.

@lilleyse
Copy link
Contributor

lilleyse commented Apr 2, 2020

CesiumJS 1.68.0 was released yesterday with the fix. I tested that gltf-pipeline now works with Node 13.12.0.

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.

7 participants