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

gltf-transform cli cannot start with node16. Is there a certain node version which I have to use? #376

Closed
devjta opened this issue Oct 5, 2021 · 8 comments · Fixed by #378
Labels
bug Something isn't working package:core
Milestone

Comments

@devjta
Copy link

devjta commented Oct 5, 2021

Hi!

After running this command: npm install --global @gltf-transform/cli
I would like to start the gltf-transform cli, but then this error appears:

ode:internal/modules/cjs/loader:1126
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/jota/.nvm/versions/node/v16.3.0/lib/node_modules/@gltf-transform/cli/node_modules/gl-matrix/dist/esm/vec3.js
require() of ES modules is not supported.
require() of /home/jota/.nvm/versions/node/v16.3.0/lib/node_modules/@gltf-transform/cli/node_modules/gl-matrix/dist/esm/vec3.js from /home/jota/.nvm/versions/node/v16.3.0/lib/node_modules/@gltf-transform/cli/node_modules/@gltf-transform/core/dist/core.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 vec3.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/jota/.nvm/versions/node/v16.3.0/lib/node_modules/@gltf-transform/cli/node_modules/gl-matrix/package.json.

To Reproduce

  1. Install node16
  2. Install gltf-transform cli with npm install --global @gltf-transform/cli
  3. Try to run gltf-transform
  4. See error

Expected behavior
No error..

Versions:

  • Version: 0.12.15
  • Environment: Ubuntu 18.04
@devjta devjta added the bug Something isn't working label Oct 5, 2021
@pawel-marciniak
Copy link

pawel-marciniak commented Oct 5, 2021

I have exactly same issue while using it in script by importing things - #375 , also on Node 16.x. I wasted half a day on trying to make it work :/

It looks like it's trying to use @gltf-transform/core/dist/core.js, which is CommonJS I think, there is also @gltf-transform/core/dist/core.modern.js, which I suppose should be ES6 syntax, but it also has require() references in it...

@koeckc
Copy link

koeckc commented Oct 5, 2021

To make it even more weird ...
Yesterday i installed on my mac ... and it worked
node v14.17.3
MacOS BigSur
gltf-transform -v 0.12.15

Today on other machines not anymore .... really spooky

@devjta
Copy link
Author

devjta commented Oct 5, 2021

I found the issue... Its gl-matrix 3.4.0. It works fine, if I use gl-matrix 3.3.0.

Currently I just copied it into the project-folder/cli/node_modules. Then it starts fine.

Yeah, a new gl-matrix version (3.4.0) was published 14 hours ago:
https://www.npmjs.com/package/gl-matrix

Thats why the error only appears now.

@donmccurdy
Copy link
Owner

The integration tests check Node.js v12 and v14 so probably those are the safest options. I'll try adding v16 to the tests and see what happens – was v16 working before the gl-matrix dependency update for anyone?

It looks like gl-matrix has already gotten reports about this (toji/gl-matrix#439) and are planning to revert 3.4.0 shortly. I'll see about switching this project's production dependencies to ~ instead of ^ as well.

@pawel-marciniak
Copy link

Ok, so they published new version for gl-matrix (v3.4.1), but the problem remains, only solution for now is to revert to [email protected]

@donmccurdy
Copy link
Owner

It looks like v3.4.1 fixed this for some others (toji/gl-matrix#439 (comment))... gltfjsx has dependencies:

gltfjsx -> @gltf-transform/core -> gl-matrix

Seems like there may be bigger changes still in v3.4.1 than I want to have roll out automatically (https://github.com/toji/gl-matrix/releases/tag/v3.4.1), I'll deploy a patch release pinned to 3.3.x instead.

@donmccurdy
Copy link
Owner

I've just published v0.12.16, pinned to gl-matrix@~3.3.0. Hopefully that fixes the regression, but let me know if not!

Have also added integration test coverage for Node.js v16, which seems to be working fine.

@devjta
Copy link
Author

devjta commented Oct 6, 2021

Thx for the fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants