I have installed Ubuntu Bash on Windows. I already have nodejs
and npm
on my windows machine at C:\\Program Files\\nodejs
. In the bash she
On Visual Studio -> Tools -> Options -> Projects and Solutions -> Web Package Management -> make sure $(PATH) is above all the rest. As long it is not located in the top of the list VS will try to use VS tools instead of npm.
You should also refer windows to the current npm version by following this screenshot, after try npm --version changing npm path
I just read through many threads trying to do this. There is complete documentation for setting up node, nvm and npm in wsl, here: https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2
If you already installed node and npm using the following commands,
sudo apt-get install nodejs
sudo apt-get install npm
NPM will not work. You must first uninstall them using:
sudo apt-get remove nodejs
sudo apt-get remove npm
follow the guide to completely uninstalling here: How can I completely uninstall nodejs, npm and node in Ubuntu 14.04
Then reinstall from the windows guide referenced above. The windows guide has many other useful resources.
The Tldr to install(from Microsoft Docs):
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
nvm install --lts
I had this issue in both Debian and Ubuntu (though in Ubuntu the nvm
command did work) when I was running Windows 10 version 1703. Then when I upgraded to version 1903 the problem disappeared.
Linux command for install nodejs
and npm
sudo apt-get install nodejs
sudo apt-get install npm
Set path in linux
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
reference https://github.com/microsoft/WSL/issues/3882
You can try sudo npm install
it was a solution in my particular case.
The solution provided by phucanhapril on May 24, 2017 in this thread worked for me.
To summarise, edit ~/.profile and change your PATH to this:
PATH="$HOME/bin:$HOME/.local/bin:/usr/bin:$PATH"
(By default it does not include /usr/bin)
Then run:
source ~/.profile
I am not quite sure why npm doesn't work properly in the first place, or why /usr/bin isn't in PATH by default, but the solution worked for me.