Running Node.js on WSL from Visual Studio Code


Starting with the October Insiders Build of Visual Studio Code we have added an easy way to run your Node.js applications on top of the Windows Subsystem for Linux (WSL). This is useful for developers targeting Linux or multiplatform production environments, making it possible to develop on Windows without relying on external systems or virtual machines.

We aimed at making running Node.js on WSL as easy and streamlined as possible. You will need Node.js installed and in your PATH in WSL, which can be easily done by following these instructions. In VS Code, all you need to do is add one new attribute to your launch.json:

"useWSL": true

This will make VS Code use WSL for running Node.js. Everything will work as expected, including debugging and custom runtimeExecutable settings:

Note: You will need Windows 10, build 15063 or later. If you are running an earlier version, you may encounter Error 0x80070057 when spawning WSL. If this happens you can try adding "console": "integratedTerminal" or "console": "externalTerminal" to your launch.json.

Native modules

In general, modules installed using Windows should work out of the box with Node.js spawned through WSL, and vice-versa, as long as they don't have any dependencies on native modules. Special care is needed when native modules are used.

When using native modules in WSL, those also need to be built for the Linux platform. You can do that by running the following commands from the Windows shell in the project directory:

npm install
bash -i -c "npm rebuild"

Bartosz Sosnowski and João Reis


Comments (6)

  1. Sergio says:

    Does this work for rails projects too?

    1. Not sure – haven’t ever debugged Rails from within VSCode. Give it a try and let me know @richturn_ms on Twitter.

  2. Dr. c says:

    What do the switches i and c do for the bash command shkwn

  3. nonikon says:

    What about C/C++? Or will it be supported in the future?

Skip to main content