I have node
installed on my Windows 11 machine (on the Windows side).
I also have WSL2 setup and am trying to install the linux version of Node.js there.
After running the standard Ubuntu setup script for Node.js LTS:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
node
runs fine, but npm
does not:
cameron@Nook:~$ node --version
v14.17.4
cameron@Nook:~$ npm --version
-bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
cameron@Nook:~$ which npm
/usr/bin/npm
cameron@Nook:~$ /usr/bin/npm --version
6.14.14
cameron@Nook:~$ which node
/usr/bin/node
cameron@Nook:~$ /usr/bin/node --version
v14.17.4
cameron@Nook:~$ whereis npm
npm: /usr/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd /mnt/c/Users/camer/AppData/Roaming/npm/npm /mnt/c/Users/camer/AppData/Roaming/npm/npm.cmd /mnt/c/Users/camer/AppData/Roaming/npm/npm.ps1
Curiously, which
finds the expected version of npm
but I have to run it directly to get it to work as expected. What is missing here?
I've seen solutions that suggest messing with the $PATH
, but I don't see why that should be necessary.
Update: My PATH
has linux paths listed first...
cameron@Nook:~$ tr ':' '\n' <<< $PATH
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/usr/lib/wsl/lib
/mnt/c/Program Files/Microsoft/jdk-16.0.1.9-hotspot/bin
/mnt/c/TwinCAT/Common64
/mnt/c/TwinCAT/Common32
/mnt/c/Python39/Scripts/
/mnt/c/Python39/
/mnt/c/Python38/Scripts/
/mnt/c/Python38/
/mnt/c/WINDOWS/system32
/mnt/c/WINDOWS
/mnt/c/WINDOWS/System32/Wbem
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
/mnt/c/WINDOWS/System32/OpenSSH/
/mnt/c/ProgramData/chocolatey/bin
/mnt/c/Program Files (x86)/STMicroelectronics/STM32 ST-LINK Utility/ST-LINK Utility
/mnt/c/Program Files/Java/jdk1.8.0_211/bin
/mnt/c/Program Files (x86)/Yarn/bin/
/mnt/c/MinGW/msys/1.0/bin/
/mnt/c/Program Files (x86)/Wolfram Research/WolframScript/
/mnt/c/Program Files/Git/cmd
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/nodejs/
/mnt/c/Users/camer/.windows-build-tools/python27/
/mnt/c/Users/camer/bin
/mnt/c/Users/camer/AppData/Local/Microsoft/WindowsApps
/mnt/c/Program Files (x86)/Nmap
/mnt/c/Users/camer/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Program Files (x86)/Avrdude
/mnt/c/Users/camer/AppData/Local/Yarn/bin
/mnt/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin
/mnt/c/Users/camer/AppData/Local/gitkraken/bin
/mnt/c/Program Files/GNU Octave/Octave-6.2.0/mingw64/bin
/mnt/c/Users/camer/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/camer/AppData/Roaming/npm
/snap/bin
Yes, I could probably clean some of these extra PATH
s up but I don't see how this is affecting things. The linux PATH
s are first...
I also do not have any weird aliases active:
cameron@Nook:~$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
PS, no, I will not be using nvm
or n
. They are anti-patterns, imho.