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
相关文章
|
8月前
|
小程序
小程序wepy踩坑-Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'
小程序wepy踩坑-Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'
174 0
|
JavaScript
Vue报错:This dependency was not found: vuex in ./node_modules/babel-loader/lib
Vue报错:This dependency was not found: vuex in ./node_modules/babel-loader/lib
973 0
Vue报错:This dependency was not found: vuex in ./node_modules/babel-loader/lib
|
2月前
报错/ ./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)怎么解决?
|
2月前
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
vue2项目安装出现Syntax Error: Error: Cannot find module ‘less‘
21 0
|
2月前
Module build failed (from ./node_modules/eslint-loader/index.js)
Module build failed (from ./node_modules/eslint-loader/index.js)
135 0
Module build failed (from ./node_modules/eslint-loader/index.js)
|
8月前
|
JavaScript
vue 报错:Module not found:Error:Can't resolve 'vuex' in XXX
vue 报错:Module not found:Error:Can't resolve 'vuex' in XXX
125 1
|
7月前
【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
|
11月前
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
nrm 安装后报错 Error [ERR_REQUIRE_ESM]: require() of ES Module
515 0
|
11月前
|
资源调度 JavaScript Windows
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
442 0
|
11月前
|
JavaScript
node_modulesnode-sass npm ERR command failed 解决方法
node_modulesnode-sass npm ERR command failed 解决方法
107 0