在VScode運行js代碼報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"

結果

stackoverflow answer


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM