打开工作区,在VScode的终端运行如下命令:
npm init -y
之后,名为package.json的文件就会自动生成到你目前工作区的根目录,打开,加个type:"module"即可
{
"name": "javascript",
"version": "1.0.0",
"main": "LC_7.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}