0
点赞
收藏
分享

微信扫一扫

Cannot use import statement outside a module

参考资料:https://www.jianshu.com/p/60a8a74f5eee?ivk_sa=1024320u

 使用 vs code 调试js 代码,出现如上报错

解决过程:

  1. npm init -y
  2. 在 package.json 中添加字段 type

package.json
{
"name": "promise",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}

举报

相关推荐

0 条评论