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

require not working with dist-node #338

Open
CutiePi opened this issue Nov 10, 2022 · 3 comments
Open

require not working with dist-node #338

CutiePi opened this issue Nov 10, 2022 · 3 comments

Comments

@CutiePi
Copy link

CutiePi commented Nov 10, 2022

dist-node should work with require but it complains with import errors on a sub dependency.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/jasmin/projects/solargraf-api/node_modules/quick-lru/index.js
require() of ES modules is not supported.
require() of /home/jasmin/projects/solargraf-api/node_modules/quick-lru/index.js from /home/jasmin/projects/solargraf-api/node_modules/geotiff/dist-node/source/blockedsource.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/jasmin/projects/solargraf-api/node_modules/quick-lru/package.json.
@CutiePi
Copy link
Author

CutiePi commented Nov 10, 2022

Not sure if I'm missing something. I expect the node-dist to work with const GeoTIFF = require('geotiff'); as is.

@CutiePi
Copy link
Author

CutiePi commented Nov 10, 2022

Note we were using an older version and it works.

@zhanghjtx
Copy link

zhanghjtx commented Mar 14, 2023

I aslo have same question, and use nestjs to import it also exist.

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

No branches or pull requests

2 participants