Pana / nrm

NPM registry manager, fast switch between different registries: npm, cnpm, nj, taobao
MIT License
2.77k stars 242 forks source link

what happen for this case #151

Open liuseen-l opened 1 year ago

liuseen-l commented 1 year ago

/usr/local/lib/node_modules/nrm/cli.js:9 const open = require('open'); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/nrm/node_modules/open/index.js from /usr/local/lib/node_modules/nrm/cli.js not supported. Instead change the require of index.js in /usr/local/lib/node_modules/nrm/cli.js to a dynamic import() which is available in all CommonJS modules. at Object. (/usr/local/lib/node_modules/nrm/cli.js:9:14) { code: 'ERR_REQUIRE_ESM' }

Node.js v18.15.0 C02F63FKMD6R:1.js bytedance$

yixiaojiu commented 1 year ago

I also encounted this error when I was using Node.js v19.8.1 and v18.12.1 :sweat:

halaproliu commented 1 year ago

This is because nrm depend on a package called open.I got this error too yesterday!You can fix this error by use this command!npm install -g nrm open@8.4.2 --save

heeronchang commented 1 year ago

/usr/local/lib/node_modules/nrm/cli.js:9 const open = require('open'); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/nrm/node_modules/open/index.js from /usr/local/lib/node_modules/nrm/cli.js not supported. Instead change the require of index.js in /usr/local/lib/node_modules/nrm/cli.js to a dynamic import() which is available in all CommonJS modules. at Object. (/usr/local/lib/node_modules/nrm/cli.js:9:14) { code: 'ERR_REQUIRE_ESM' }

Node.js v18.15.0 C02F63FKMD6R:1.js bytedance$

Just change const open = require('open'); to const open = import('open'); at /usr/local/lib/node_modules/nrm/cli.js line 9. It works for me.

RoYouL commented 1 year ago

/usr/local/lib/node_modules/nrm/cli.js:9 const open = require('open'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/nrm/node_modules/open/index.js from /usr/local/lib/node_modules/nrm/cli.js not supported. Instead change the require of index.js in /usr/local/lib/node_modules/nrm/cli.js to a dynamic import() which is available in all CommonJS modules. at Object. (/usr/local/lib/node_modules/nrm/cli.js:9:14) { code: 'ERR_REQUIRE_ESM' } Node.js v18.15.0 C02F63FKMD6R:1.js bytedance$

Just change const open = require('open'); to const open = import('open'); at /usr/local/lib/node_modules/nrm/cli.js line 9. It works for me.

That works, thx a lot

maxiaoqu commented 1 year ago

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