我們?cè)谑褂胣rm工具進(jìn)行配置淘寶鏡像過(guò)程中使用cmd命令
nrm use taobao
結(jié)果出現(xiàn)這樣的報(bào)錯(cuò)
C:\Windows\system32>nrm use taobao // 這里是我們?cè)赾md 的指令
D:\nodejs\node_global\node_modules\nrm\cli.js:9
const open = require('open'); // 出現(xiàn)錯(cuò)誤提示在(D:\nodejs\node_global\node_modules\nrm\cli.js:9:14)文件的第九行出現(xiàn)錯(cuò)誤,說(shuō)是require不支持,然后我們將cli.js中的require換成了import,保存后再次運(yùn)行成功。
^
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\nodejs\node_global\node_modules\nrm\node_modules\open\index.js from D:\nodejs\node_global\node_modules\nrm\cli.js not supported.
Instead change the require of index.js in D:\nodejs\node_global\node_modules\nrm\cli.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (D:\nodejs\node_global\node_modules\nrm\cli.js:9:14) {
code: 'ERR_REQUIRE_ESM'
}
?根據(jù)提示錯(cuò)誤出現(xiàn)在(D:\nodejs\node_global\node_modules\nrm\cli.js:9:14)文件的第九行
我們查看下nrm\cli.js文件
原因:
require不支持,然后我們將cli.js中的require換成了import,保存后再次運(yùn)行成功。
然后再次運(yùn)行
nrm use taobao
?即可完成配置。
在網(wǎng)上查找原因時(shí),發(fā)現(xiàn)一個(gè)博主下的評(píng)論:
下面就是這個(gè)博主的博文:
?NodeJS 如何修復(fù)“ERR_REQUIRE_ESM”錯(cuò)誤? _大數(shù)據(jù)知識(shí)庫(kù)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-504797.html
也可能是Chalk版本的問(wèn)題,不過(guò)大家要具體問(wèn)題具體分析,這是我的一些見(jiàn)解。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-504797.html
到了這里,關(guān)于nrm工具配置淘寶鏡像 Error [ERR_REQUIRE_ESM]: require() of ES Module ... code: ‘ERR_REQUIRE_ESM‘的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!