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

(node:35442) Warning: require() of ES modules is not supported. #225

Closed
aaronxowen opened this issue Nov 26, 2019 · 4 comments · Fixed by #237
Closed

(node:35442) Warning: require() of ES modules is not supported. #225

aaronxowen opened this issue Nov 26, 2019 · 4 comments · Fixed by #237

Comments

@aaronxowen
Copy link

I am trying to convert an obj that doesn't reference an mtl to GLB using PBR textures explicitly set by the option flags using the following command:

obj2gltf -i Monaco1-DrawerNightstand_82334_low_scaled.obj -o Monaco1-DrawerNightstand_82334_ClassicPaint_CoastalClear_PolishedNickel.glb -b --baseColorTexture Monaco1-DrawerNightstand_82334_ClassicPaint_CoastalClear_PolishedNickel_Albedo.jpg --normalTexture Monaco1-DrawerNightstand_82334_ClassicPaint_CoastalClear_PolishedNickel_Normal_OpenGL.png --metallicRoughnessOcclusionTexture Monaco1-DrawerNightstand_82334_ClassicPaint_CoastalClear_PolishedNickel_MetallicRoughnessOcclusionRGB.jpg

When run, I get this:
(node:35442) Warning: require() of ES modules is not supported. require() of /usr/local/lib/node_modules/obj2gltf/node_modules/cesium/index.js from /usr/local/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/local/lib/node_modules/obj2gltf/node_modules/cesium/package.json. ENOENT: no such file or directory, open '/Users/aaron/Desktop/GLTF_tests/iOS_Optimized/Monaco1-DrawerNightstand_82334_low_scaled.obj'

A GLB file is output, but doesn't seem to have the correct maps in place.

@lilleyse
Copy link
Contributor

@aaronxowen CesiumJS was recently updated to ES6 so it's possible that's related to the warning. A few questions...

  • What Node version are you using?
  • Do you see the same warning if you try to convert the obj to gltf without the material options?
  • Can you confirm that the obj exists? I'm trying to figure out why this error message shows up: ENOENT: no such file or directory, open '/Users/aaron/Desktop/GLTF_tests/iOS_Optimized/Monaco1-DrawerNightstand_82334_low_scaled.obj'

I'm not seeing any issues on my end after updating packages but there could be a few different factors at play.

@aaronxowen
Copy link
Author

Originally I tried to use 13.2.0, but couldn't get it to run at all on the command line (macOS 10.14.6), so I switched to node 12.13.1 and it runs, but with those errors.

I believe that the "ENOENT: no such file or directory" error is related to the .obj not referencing a mtl at all. I had exported the obj from Maya with materials turned off, so there were no "usemtl" or "mtllib" statements in the obj. I thought I'd be able to override the lack of mtl with specific mappings to external texture files like I do with Apple's python USDZ converter.

If I run obj2gltf on an obj that references a mtl file and override with the flags for external texture map files, it appears to work correctly, but still throws the warning about require():

(node:51774) Warning: require() of ES modules is not supported. require() of /usr/local/lib/node_modules/obj2gltf/node_modules/cesium/index.js from /usr/local/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/local/lib/node_modules/obj2gltf/node_modules/cesium/package.json. Total: 1032.669ms

@lilleyse
Copy link
Contributor

@aaronxowen we're tracking this from the cesium side - CesiumGS/cesium#8452

We hope to have a fix by the next Cesium release on Jan 2.

@lilleyse
Copy link
Contributor

lilleyse commented Apr 2, 2020

CesiumJS 1.68.0 was released yesterday with the fix. I tested that obj2gltf 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.

2 participants