javascript - 使用 VSCode 调试 node.js ES6 代码

标签 javascript node.js

我遵循了这本手册: 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/

相关文章:

javascript - Node 中的异步方法没有收到错误

node.js - 如何在 Node.js 中拦截 fs.createWriteStream 的回调

javascript - 是否可以删除新字符下输入文本字段的底部边框?

javascript - ExtJS FiltersFeature 不再工作

javascript - 使用 CKEditor 进行内联编辑

node.js - Express - 如何修改请求然后重定向到另一条路线?

angularjs - 无法获取从 Angular 发送到 Node 服务器的表单数据

javascript - Node JS在ejs文件中加载js和css文件

javascript - 如何在javascript中比较UTC时间

javascript - 高级 JavaScript 拆分