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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like