Npm Command Not Found in Wsl

Npm Command Not Found in Wsl

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

1 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)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.