(base) a0@Mac-mini wyt0724 % npx nrm use taobao
/Users/a0/.npm/_npx/c3b18f2de609c2ae/node_modules/nrm/cli.js:9
const open = require('open');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/a0/.npm/_npx/c3b18f2de609c2ae/node_modules/open/index.js from /Users/a0/.npm/_npx/c3b18f2de609c2ae/node_modules/nrm/cli.js not supported.
Instead change the require of index.js in /Users/a0/.npm/_npx/c3b18f2de609c2ae/node_modules/nrm/cli.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/a0/.npm/_npx/c3b18f2de609c2ae/node_modules/nrm/cli.js:9:14) {
code: 'ERR_REQUIRE_ESM'
}
这个错误消息表明你在运行 npx nrm use taobao
命令时遇到了一个问题,因为在Node.js模块中使用了ES模块(ES Module)的require
语法,而该语法在这个上下文中不受支持。
npm install -g nrm@latest
npm install -g open@latest
切换Node.js版本:尝试在Node.js的不同版本中运行命令,可能某些Node.js版本对ES模块的支持不同。
使用旧版本的nrm
:如果最新版本的nrm
存在问题,你可以尝试回退到较旧的版本:
npm install -g nrm@x.x.x
以上答案出自chatGPT