Home > OS >  VS Code-debugger, How to use node with command line option in launch.json for starting a script
VS Code-debugger, How to use node with command line option in launch.json for starting a script

Time:01-11

The script that is meant must be executed with the command

node --no-experimental-fetch server.js

otherwise a error occurs.

To use the VS Code-debugger and not to start the script always with the shell, I want to integrate the command in the launch.json.

I generated and edited the following launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Start server",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "args": [
                "--no-experimental-fetch"
            ],
            "program": "${workspaceFolder}/server.js"
        }
    ]
}

but the error occurs.

Has someone an idea what should be edit in the launch.json that fixes the issue? Thanks for reading and answering this question, I appreciate it.

CodePudding user response:

Instead of "args" you should use "runtimeArgs" with arguments for node(.exe).

You might as well use environment variable definition for "NODE_OPTIONS":

...
  env: {
    "NODE_OPTIONS": "--no-experimental-fetch"
  },
...
  • Related