-
安装
nrm后,进行使用时报错$ npm i -g nrm/Users/xxx/.nvm/versions/node/v16.20.0/lib/node_modules/nrm/cli.js:9 const open = require('open'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/xxx/.nvm/versions/node/v16.20.0/lib/node_modules/nrm/node_modules/open/index.js from /Users/lixiaoxia/.nvm/versions/node/v16.20.0/lib/node_modules/nrm/cli.js not supported. Instead change the require of index.js in /Users/xxx/.nvm/versions/node/v16.20.0/lib/node_modules/nrm/cli.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/Users/xxx/.nvm/versions/node/v16.20.0/lib/node_modules/nrm/cli.js:9:14) { code: 'ERR_REQUIRE_ESM' } -
原因:应该使用
open的CommonJs规范的包,现在open v9.0.0是ES Module版本的包。 -
解决方案:
$ npm i -g nrm open@8.4.2 --save