Open liuseen-l opened 1 year ago
I also encounted this error when I was using Node.js v19.8.1 and v18.12.1 :sweat:
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
/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.
/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');
toconst open = import('open');
at /usr/local/lib/node_modules/nrm/cli.js line 9. It works for me.
That works, thx a lot
you can run bash as “npm install invm -g”,details view in: https://github.com/maxiaoqu/nrm
/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$