我遵循了这本手册: https://blogs.msdn.microsoft.com/vscode/2015/07/06/visual-studio-code-es6/
并将其添加到我的 jsconfig.json
文件中:
{
// See https://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"files": [
"app.js"
]
}
添加到 app.js 时:
let myVar;
我遇到语法错误:
let myVar;
^^^^^
如果我将 let
更改为 var
- 一切都很好。
怎么了?
我相信这与 VSCode 运行 Node 的方式有关:
node --debug-brk=30696 --nolazy bin/www
debugger listening on port 30696
最佳答案
通过升级 Node +向 .vscode\launch.json
添加 harmony arg 修复:
"runtimeArgs": [
"--nolazy",
"--harmony"
],
关于javascript - 使用 VSCode 调试 node.js ES6 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38377714/