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
WSL prefers NodeJS executable in Program Files over /usr/bin #1896
Comments
I've set this up locally by installing the Windows and Linux versions of nodejs and I'm not hitting the same issue as you. My shell is correctly picking up the npm in /usr/bin and not the one in Program Files. Could you share the output of the below commands? It looks like you're running into similar issues as #1890. I'd suggest overwriting your $PATH environment variable in your .bashrc file or setting the registry key that disables appending the NT path.
|
Amusingly, the strace command worked perfectly -- it ran the Linux npm. I can attach the debug output, but it probably isn't useful. I'll give the $PATH thing a try. EDIT: Oh, this is interesting. Before I did anything with $PATH or that registry key, I re-ran npm -v to make sure it still didn't work, which it didn't. Then I closed Ubuntu, and re-opened it... and now it works. |
Since I can no longer reproduce the problem, and pathing issues are being looked into, I'll close this. |
Had the same issue, and closing and opening bash solved that problem. Weird. I did uninstall Node from Windows before-hand. |
I'm running into the exact same issue. I made sure Node was not installed under Windws and installed Node LTS under WSL. Everything worked perfectly. I was able to run my servers and builds while editing under the Windows environment. Problem is that my IDE has integrations that I would like to be able to use which requires Node for Windows. I installed Node LTS For Windows and it gets added to the Windows path. Everything works fine under Windows but once I re-open a Bash on Windows instance, NPM utterly fails. Uninstalling Node for Windows and everything under WSL works again. May someone post the $PATH workaround? I may try the registry key just to keep the environment paths completely separate as at the moment I don't have a need to launch Windows executables via WSL. |
I'll reopen this since others are still seeing this issue. |
Re-installed Node for Windows (6.10.2) and this time, I set the installer to not add node and npm to the Windows path. I set my IDE to access the path to Node it requires (c:\program files\nodejs\node.exe) and invoke npm.cmd directly as well if I need to install npm modules in the Windows environment. Not ideal but seems to work for the moment. Doing the above results in WSL using the proper Linux node and npm installations and Windows will properly use the Windows Node installation as well. |
Same thing, closing Bash and reopening fixed the issue. |
Windows change npm to npm.exe fixed the issue. |
@smalike Do you mean you changed npm.cmd to npm.exe? |
@samplefrequency rename npm to npm_cygwin, since npm in program files is a bash script targeted for cygwin |
@jmalczak I ended up simply overriding the PATH variable in WSL and everything is working well now. |
Same, closing and re-opening fixed the issue. |
|
from this post I : uninstalled node from windows, open bash as administer, reinstall node in bash. Thanks all above. |
Use nvm for Ubuntu subsystem and all will be cool |
This isn't so much an issue as a requirement to restart the system or at least the terminal to update PATHs properly |
Haha found this via google again. Will re-iterate, this isn't a valid issue. PATH variables are cached when terminal/bash/cmd loads, so if you update them you always need to close the open window and open a new bash to access new commands. Close this. |
Simply set your path in WSL |
The OP is missing There are some suggestions on using node with WSL here. |
I've just tried installing NodeJS on WSL, after running the Creators Update and doing a fresh WSL install to get 16.04.
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Running node works fine:
But npm doesn't work:
It seems to be trying to run the npm executable from Windows. I tried some other things:
So it obviously knows where the Linux npm is, and it seems to think that's the preferred one, but it doesn't run that one for some reason. And it clearly works if I specify the absolute path to npm.
The text was updated successfully, but these errors were encountered: