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
相关文章
|
小程序
小程序wepy踩坑-Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'
小程序wepy踩坑-Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'
230 0
|
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)怎么解决?
|
应用服务中间件 网络安全 nginx
./configure: error: SSL modules require the OpenSSL library.
CentOS 6.5 下 安装 Tengine 执行配置命令./configure  时提示以下错误: ./configure: error: SSL modules require the OpenSSL library.
1968 0
|
6月前
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
90 0
|
6月前
Module build failed (from ./node_modules/eslint-loader/index.js)
Module build failed (from ./node_modules/eslint-loader/index.js)
188 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
191 1
|
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
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
617 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/
651 0
|
JavaScript
node_modulesnode-sass npm ERR command failed 解决方法
node_modulesnode-sass npm ERR command failed 解决方法
276 0