0

Recently I installed WSL and started using it. In WSL, I installed NVM in order to have Node.js 6.11.5 and 8.9.0 at the same, I can install NPM packages and run my apps developed in Windows without any problems. As NPM worked fine, I uninstalled Node.js from Windows (I no longer use it). Now, when I open VSCode (Windows App), it tells me that I have to install NPM. I don't want to reinstall Node.js for Windows, I want VSCode to use NPM that exists in my WSL. How can I achieve this?

1

You can't your options are to install VSCode within WSL (if possible) and use that instance or you will have to reinstall Node.js for Windows.

WSL is a complete Linux system running alongside Windows. It's using it's own binary format, it's own security mechanisms and so on. You can't use integral components from one system in the other if they are closely intertwined.

  • I can, however, use NPM that is installed in WSL to do an npm install inside a project directory in Windows. How is it possible then? – Ghassen Rjab Nov 2 '17 at 9:31
  • From what kind of console are you issuing the command? Are you running it inside WSL or outside of it? npm install is just a file operation. You do have access to the file system from WSL. – Seth Nov 2 '17 at 9:49
  • From WSL, I got to my Windows directory cd /mnt/c/path/to/project and execute npm install. It works fine – Ghassen Rjab Nov 2 '17 at 9:51
  • 1
    You're working within the WSL environment with the linux binaries of npm to trigger filesystem operations. You're not running npm within Windows with that command. Doing the reverse (preparing a file in Windows and copying it into the WSL environment) might also work. But you can't run say cmd.exe within WSL or similar. – Seth Nov 2 '17 at 9:57
0

The Microsoft blog post below somewhat contradicts the accepted answer. It is true that WSL is it's own environment, but VS Code has built in support for using it...

https://blogs.msdn.microsoft.com/commandline/2017/10/27/running-node-js-on-wsl-from-visual-studio-code/

An older blog post suggests adding this to the settings...

"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\bash.exe"

http://daverupert.com/2017/03/my-bash-on-windows-developer-environment/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.