原因:
使用code runner调试js时,使用ES6的import export,报错(node:5600) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
文件1:
文件2:
1.导入文件1,报错(node:5600) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
解决:
1.使用npm init 生成一个package.json
2.在package.json中添加"type": "module",如下图所示: