Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
KhaledSharif opened this issue · 1 comments
KhaledSharif commented
After installing obj2gltf
as a command line tool:
khaled@khaled:~/Desktop/texrecon$ sudo npm install -g obj2gltf
/usr/bin/obj2gltf -> /usr/lib/node_modules/obj2gltf/bin/obj2gltf.js
+ obj2gltf@3.0.4
added 37 packages from 30 contributors in 9.616s
Trying to run it results in an error:
khaled@khaled:~/Desktop/texrecon$ obj2gltf -i ./tr.obj -o ./tr.gltf
internal/modules/cjs/loader.js:1167
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/lib/node_modules/obj2gltf/node_modules/cesium/index.js
require() of ES modules is not supported.
require() of /usr/lib/node_modules/obj2gltf/node_modules/cesium/index.js from /usr/lib/node_modules/obj2gltf/bin/obj2gltf.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 /usr/lib/node_modules/obj2gltf/node_modules/cesium/package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:13)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/usr/lib/node_modules/obj2gltf/bin/obj2gltf.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14) {
code: 'ERR_REQUIRE_ESM'
}
Environment:
khaled@khaled:~/Desktop/texrecon$ uname -a
Linux khaled 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
khaled@khaled:~/Desktop/texrecon$ node -v
v13.9.0
lilleyse commented
@KhaledSharif we're tracking the problem here: #225
In the meantime you'll need to use Node 12