Reputation: 17394
I want to use debug in Visual Studio Code, but as my code full of const declarations, I can't run it - I'm getting an error:
Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Is any workaround existed, configuration file setting or something? Currently, my configuration file looks like this:
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/server.js"
}
]
I've seen posts about 'use strict' line, but I was wandering if there is another solution, except putting that statements in all the files
Upvotes: 0
Views: 499
Reputation: 16109
You say above that you normally start the app from an npm script: "start": "nodemon --exec babel-node server.js --ignore public/"
. Babel is transpiling your code and probably inserting "use strict"
. To debug this in vscode, you should invoke the same command.
There are a few ways to set it up, one would be to follow the example here: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration-support-for-npm-and-other-tools, to add the debug arg to your npm script, then point the launch config at the npm script.
Upvotes: 1