目錄
? 報錯信息
?? 解決方案
?? 執(zhí)行結(jié)果
? 報錯信息
vscode運行js代碼報錯:(node:20452) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.?

# 查看報錯信息
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
警告:加載ES模塊時,在package.json包中設置“ type”:“ module”或使用.mjs擴展名。
?? 解決方案
# 解決方法
1、安裝新版node.js
2、使用npm init -y初始化項目,生成一個pakeage.json文件
3、在pakeage.json文件中添加"type": "module"
同類型報錯的情況,都可以使用該方案解決!文章來源:http://www.zghlxwxcb.cn/news/detail-715395.html

?? 執(zhí)行結(jié)果

文章來源地址http://www.zghlxwxcb.cn/news/detail-715395.html
到了這里,關(guān)于解決運行js代碼報錯—Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!