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

throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); #156

Open
maxiaoqu opened this issue Apr 12, 2023 · 10 comments
Open

throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); #156

maxiaoqu opened this issue Apr 12, 2023 · 10 comments

Comments

@maxiaoqu
Copy link

maxiaoqu@maxiaoqudeMacBook-Pro ~ % nrm ls
internal/modules/cjs/loader.js:1131
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/maxiaoqu/.nvm/versions/node/v14.21.3/lib/node_modules/nrm/node_modules/open/index.js
require() of ES modules is not supported.
require() of /Users/maxiaoqu/.nvm/versions/node/v14.21.3/lib/node_modules/nrm/node_modules/open/index.js from /Users/maxiaoqu/.nvm/versions/node/v14.21.3/lib/node_modules/nrm/cli.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/maxiaoqu/.nvm/versions/node/v14.21.3/lib/node_modules/nrm/node_modules/open/package.json.

@maxiaoqu
Copy link
Author

use node version is 14.21.3

@panjinghui
Copy link

I have the same problem as you. Do you have a solution?

@maxiaoqu
Copy link
Author

@panjinghui can use nrm-sunny1011111,you can run bash as "npm i nrm-sunny1011111 -g"!

@solfKwolf
Copy link

use this command:

use this command: npm install -g nrm open@8.4.2 --save

@maxiaoqu
Copy link
Author

i use myself package with inrm,you can run bash as “npm install invm -g”,details view in: https://github.com/maxiaoqu/nrm

@tldzyx
Copy link

tldzyx commented May 17, 2023

use node version is 14.21.3 too, I don't sure which old version support, who meet the same wrong.

@xllily
Copy link

xllily commented May 23, 2023

use this command:

use this command: npm install -g nrm open@8.4.2 --save

not work for me , but borrow the idea, so i try:

  1. find the nrm global installed dir {{your_global_node_module_path}}/node_modules/nrm/
  2. rm the nrm/node_modules and nrm/package-lock.json (if there is)
  3. edit nrm/package.json, change "open":">=6.0.0" to "open":"8.4.2"
  4. last, npm install(in the current nrm dir)

done, nrm ls success, work for me.

@CaptainOfPhB
Copy link
Contributor

CaptainOfPhB commented Aug 26, 2023

Try npm i -g nrm-ng.

@naiemhosen430
Copy link

in my case, localhost is working fine but now I am deploying it to the Namecheap server there is 14.21.2 and not working. What do you think I should do now?

@k-enagy
Copy link

k-enagy commented Dec 14, 2023

in my case, localhost is working fine but now I am deploying it to the Namecheap server there is 14.21.2 and not working. What do you think I should do now?

same problem here there is no require in my index.js file

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

8 participants