Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start nodejs with custom params from vscode

Tags:

Is there any way to start nodeJS with additional command line parameters?

like:

--harmony_generators
--harmony_arrow_functions

UPD:

workaround for now:

  1. create .bat (windows) file with:

    • {{path-to-node}}\node.exe --harmony_generators --harmony_arrow_functions %*
  2. add path to your .bat file as source of runtimeExecutable in .\settings\launch.json

  3. profit :)

like image 978
leximus Avatar asked Apr 30 '15 13:04

leximus


People also ask

How do I start node server in VS Code?

Open app.js and set a breakpoint near the top of the file where the Express app object is created by clicking in the gutter to the left of the line number. Press F5 to start debugging the application. VS Code will start the server in a new terminal and hit the breakpoint we set.

How do you add parameters in VS Code?

Select the down arrow on the Quick Actions menu, and then select Add parameter to [method].

How do I run a node js script code in Visual Studio?

Open integrated terminal on visual studio code ( View > Integrated Terminal ) type 'node filename. js' press enter.

How do I change the launch configuration in VS Code?

The simplest way to go about this is to simply locate your file folder and delete the launch. js file or delete the . vscode folder. This should return your launcher settings to default.


2 Answers

In the preview version of VSCode it is not yet possible to pass arguments to node from the launch.json. But the workaround mentioned above works fine. I have created a bug on our side and will make sure it’s fixed with the next release.

Andre Weinand, Visual Studio Code


Update:

The fix is in VSCode since v0.3 with this in .settings/launch.json:

"configurations": [
    {
        ...

        // Optional arguments passed to the runtime executable.
        "runtimeArgs": [],

        ...

So to e.g. run Node.js (v0.12) with ES6 support use "runtimeArgs": ["--harmony"],

like image 170
Andre Weinand Avatar answered Sep 19 '22 14:09

Andre Weinand


In My case I was running this command and parameter: node app.js read --title="SomeTitle"

and to solve that i used this:

"args": [
            "read",
            "\--\--title\=='SomeTitle'"
        ]

and the output was this:

node --inspect=10398 --debug-brk app.js read --title='Title'

That suited me well.

The suggestion to use runtimeArgs don't worked for me because its passed "before" invoking my app.js.

like image 30
cyberwillis Avatar answered Sep 18 '22 14:09

cyberwillis