I have installed Node and npm on Ubuntu 20.04 on WSL2. Node runs fine. However, when typing npm on the command line, it appears to be loading the npm which is in /mnt/c/Program Files/nodejs. Running npm -v will result in:
-bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
which npm shows that my npm is /usr/bin/npm.
/usr/bin is in my PATH variable above /mnt/c/Program Files/nodejs. Output of process.env.PATH.split(":") is:
[ '/usr/local/sbin',
'/usr/local/bin',
'/usr/sbin',
'/usr/bin',
'/sbin',
'/bin',
...
'/mnt/c/Python27',
'/mnt/c/Program Files/nodejs/',
...
]
Why is it running npm from the wrong location and how do I fix this?