ohadinho
ohadinho

Reputation: 7144

Debugging node.js ES6 code with VSCode

I followed this manual: https://blogs.msdn.microsoft.com/vscode/2015/07/06/visual-studio-code-es6/

And added this to my jsconfig.json file:

{
    // 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:

let myVar;

I'm getting a syntax error:

let myVar;
    ^^^^^

If I change let to var - it's all good. What is wrong? I believe it's related to the way VSCode runs node:

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

Upvotes: 1

Views: 396

Answers (2)

ohadinho
ohadinho

Reputation: 7144

Fixed by upgrading node + adding harmony arg to .vscode\launch.json :

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

Upvotes: 2

Rafael Dantas
Rafael Dantas

Reputation: 599

The correct file extension is jsconfig.json and in target place ES6.

Upvotes: 1

Related Questions