nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module

简介: nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
  • 安装 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'  
}
  • 原因:应该使用 openCommonJs 规范的包,现在 open v9.0.0ES Module 版本的包。
  • 解决方案:
$ npm i -g nrm open@8.4.2 --save
相关文章
|
6月前
报错/ ./node_modules/axios/lib/platform/index.js Module parse failed: Unexpected token (5:2)怎么解决?
报错/ ./node_modules/axios/lib/platform/index.js Module parse failed: Unexpected token (5:2)怎么解决?
|
6月前
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
610 0
|
6月前
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
92 0
|
6月前
Module build failed (from ./node_modules/eslint-loader/index.js)
Module build failed (from ./node_modules/eslint-loader/index.js)
189 0
Module build failed (from ./node_modules/eslint-loader/index.js)
|
JavaScript
vue 报错:Module not found:Error:Can't resolve 'vuex' in XXX
vue 报错:Module not found:Error:Can't resolve 'vuex' in XXX
195 1
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
1113 0
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
|
11月前
【Error】This dependency was not found: * core-js/modules/es.error.cause.js in ./node_modules/@babel
【Error】This dependency was not found: * core-js/modules/es.error.cause.js in ./node_modules/@babel
导出与导入(require,import,module.exports,exports,export,export default)
导出与导入(require,import,module.exports,exports,export,export default)
65 0
|
资源调度 JavaScript Windows
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
652 0
|
JavaScript
node_modulesnode-sass npm ERR command failed 解决方法
node_modulesnode-sass npm ERR command failed 解决方法
287 0