简体   繁体   English

使用VSCode调试node.js ES6代码

[英]Debugging node.js ES6 code with VSCode

I followed this manual: https://blogs.msdn.microsoft.com/vscode/2015/07/06/visual-studio-code-es6/ 我遵循了这本手册: https//blogs.msdn.microsoft.com/vscode/2015/07/06/visual-studio-code-es6/

And added this to my jsconfig.json file: 并将其添加到我的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"
    ]
}

When adding to app.js: 添加到app.js时:

let myVar;

I'm getting a syntax error: 我收到语法错误:

let myVar;
    ^^^^^

If I change let to var - it's all good. 如果我改变let to var - 这一切都很好。 What is wrong? 怎么了? I believe it's related to the way VSCode runs node: 我相信它与VSCode运行节点的方式有关:

node --debug-brk=30696 --nolazy bin/www 
debugger listening on port 30696

Fixed by upgrading node + adding harmony arg to .vscode\\launch.json : 通过升级node +将harmony arg添加到.vscode\\launch.json.vscode\\launch.json

"runtimeArgs": [
                "--nolazy",
        "--harmony"
            ],

The correct file extension is jsconfig. 正确的文件扩展名是jsconfig。 json and in target place ES6 . json和目标位置ES6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM