Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node integration issues with Windows 10 WSL #42289

Closed
zoomclub opened this issue Jan 29, 2018 · 6 comments
Closed

Node integration issues with Windows 10 WSL #42289

zoomclub opened this issue Jan 29, 2018 · 6 comments
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@zoomclub
Copy link

I've recently moved to Windows 10 and have found a few unexpected conundrums along the way when installing and working with Node. All I'm hoping to do is have VSCode, WSL and Node all work together.

So far, after installing VSCode v1.19.2 I used the Node v9.4.0 msi installer only to discover that Node was only visible on the Windows side (using the Node Command Prompt) and it was not found when doing a version check in the VSCode integrated terminal. I then removed the msi install and instead installed Node using NVM, following the steps on this excellent and rare site: https://www.tikalk.com/js/Installing-Node-on-Windows-Subsystem-for-Linux

This allowed me to use Node v9.4.0 from the integrated terminal except I was not able to use the super useful Code-Runner plugin. Thinking that it might be a PATH issue I finally thought I had the solution in this site: https://github.com/seanfisher/nvm-vscode. From what I had gathered from issues to this point is that the GUI and terminal sides of VSCode do not access Node under WSL in the same way. After trying nvm-vscode the Code-Runner plugin is still not working.

There seems to be something new about using Node in WSL here: https://blogs.msdn.microsoft.com/commandline/2017/10/27/running-node-js-on-wsl-from-visual-studio-code, although at this point I'm not sure what to try next?

It seems the integration between VSCode and Node is not quite perfect yet. So far my experience has not been great and a guide that brings Windows 10, WSL, Node and VSCode together would be very helpful. Essentially, what is the best way to install Node and have it work both in the GUI (Code-Runner) and the terminal?

@yume-chan
Copy link
Contributor

yume-chan commented Jan 29, 2018

  1. What shell do you use in the Integrated Terminal? PowerShell or Bash?

  2. In my case, after I installed Node.js with MSI installer on the Windows side, I can use node.exe to reference it on the WSL side. (the .exe extension is required, because it's Linux)

    root@Simon-Work:/mnt/c/Users/Simon# which node.exe
    /mnt/c/Program Files/nodejs/node.exe
    root@Simon-Work:/mnt/c/Users/Simon# node.exe -v
    v9.3.0

  3. For installing node on the WSL side, I just followed the official guide: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

  4. The Code Runner extension runs on the Windows side, so if you want it to call a program on the WSL side, you need to prefix bash to it, and translate the file path to Linux style. I haven't found a way to configure Code Runner to do it.

@zoomclub
Copy link
Author

Coming from a Mac background I'm definitively using Bash in the integrated terminal, thinking of changing to Fish once things are working :)

From your points 2 and 3 it sounds like you may have Node installed on both sides? Maybe that is a way to go or else the following link might have a solution?

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

Sounds like Code-Runner needs Node on the Windows side if there is no other way to configure it?

@yume-chan
Copy link
Contributor

Yes I have Node installed on both sides, because I need to build and test native node addon on both platforms.

But as I stated in point 2, maybe it's enough to install Node on Windows then use it with node.exe or set a alias for it in WSL.

The blog you linked talks about using Visual Studio Code to debug Node scripts running in WSL, which is not quite relative to your problem.

@zoomclub
Copy link
Author

Setting the alias in WSL for node.exe is what I do not know how to do. I this done in bashrc or somewhere in VSCode or elsewhere?

My experience editing bashrc by opening it in VSCode has not been great, as far as I can tell editing files from the WSL side on the Windows side will destroy them, see these issues:

microsoft/WSL#87
microsoft/WSL#45

@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Jan 29, 2018
@vscodebot
Copy link

vscodebot bot commented Jan 29, 2018

Please ask your question on StackOverflow. We have a great community over there. They have already answered thousands of questions and are happy to answer yours as well. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Jan 29, 2018
@zoomclub
Copy link
Author

zoomclub commented Jan 30, 2018

Awesome, Code-Runner now works with Node under WSL, see:

formulahendry/vscode-code-runner#247

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants