Pana / nrm

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

node version v16.18.0 ERROR: ERR_REQUIRE_ESM #147

Closed BigHugeC4 closed 1 year ago

BigHugeC4 commented 1 year ago

const open = require('open'); ^

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

BigHugeC4 commented 1 year ago

"open" use version 8.4.2 is fine

276378532 commented 1 year ago

遇到了同样的问题 插眼

wanglin447563345 commented 1 year ago

遇到了同样的问题 插眼

LuoRiWuSheng commented 1 year ago
package version
node 14.19.3
npm 6.14.17
window 10

从本地

npm i nrm -g

2023-03-21 9:23 分最新版本 下载的版本是 1.2.5 依赖的 open包 是 image

nrm 下的 node_modules 里面下载的是 open的最新版本

image

应该使用 open 的 CommonJs规范的包 现在 open: :9.0.0 是 ES Module 版本的

目前只能降级 nrm 为

这在 open 的github 上也是看到了 更新日志 https://github.com/sindresorhus/open/releases

image

ltchou commented 1 year ago

try to use this command to lock the version of open pacakge at 8.4.2 npm install -g nrm open@8.4.2 --save

RikaShiro commented 1 year ago

got the same error message

Diluka commented 1 year ago

just install it from GitHub directly

npm i -g github:Pana/nrm
cuihuale2021 commented 1 year ago

try to use this command to lock the version of open pacakge at 8.4.2 npm install -g nrm open@8.4.2 --save

解决问题了,感谢!

LuoRiWuSheng commented 1 year ago

just install it from GitHub directly

npm i -g github:Pana/nrm

Installing from github does not seem to be a good solution to network congestion, and there may be download failures

LuoRiWuSheng commented 1 year ago

try to use this command to lock the version of open pacakge at 8.4.2 npm install -g nrm open@8.4.2 --save 这不是nrm包的内部依赖吗,为何要单独全局安装,似乎不是很好的解决方案

像我们在 jekenis 自动发布, 以前只要 全局安装 npm - nrm -g 即可; 现在多了一个前置包 open, 对 运维也是一个负担

毕竟真的有运维搞不懂 node 和前端这个庞大的生态

xiao994 commented 1 year ago

插眼

TigerHee commented 1 year ago

same error

xllily commented 1 year ago

try to use this command to lock the version of open pacakge at 8.4.2 npm install -g nrm open@8.4.2 --save

If unresolved, also consider checking #156 as an additional option.