Npm command not found in wsl

nodejswindows-subsystem-for-linux

I had installed nodejs on windows10 & its path is also set to environment variable. It is working perfectly. As I switched to WSL I found npm commands were not working however I could run node.exe from within WSL.
Do I need to install node for wsl separately? please help me I am really a newbie. I might be asking a silly question though.
screenshot attached here

Best Answer

node.exe is NodeJS from your Windows environment - that's for Windows, not WSL.

You need to install NodeJS from the NodeJS repositories inside of WSL in order to use npm and Node within WSL. DO NOT rely on the Windows solutions for installing WSL.

Microsoft has specific documentation on how to do this, provided you're using WSL2. I would suggest following the Microsoft documentation. (Not copied here because it's a fairly involved process 'cause of making sure you've got WSL2 and such)

Related Question