59

I'm learning laravel and follwing this tutorial,

But when I went try and install npm, is says bash: npm: command not found

enter image description here

Henke
  • 4,445
  • 3
  • 31
  • 44
Deo
  • 681
  • 1
  • 6
  • 15

10 Answers10

31

If you have already installed nodejs and still getting this error. npm: command not found..

run this

apt-get install -y npm
Black Mask
  • 337
  • 3
  • 3
17

I also come here for the same problem, The solution I found is to install npm and then restart the Visual Studio Code

Naimur Hasan
  • 549
  • 11
  • 14
  • 1
    For people who wanna copy and paste the command, you install `npm` using `sudo apt-get install -y npm`. – Ishidres Aug 14 '22 at 17:16
8

I am following the same tuturial and I had this issue and how I solved is just download the

8.11.4 LTS version

from this link then install it then the command worked just fine!

Community
  • 1
  • 1
7

in redhat base OS (tested in centos 7)

yum install nodejs npm -y

in debian base OS

apt-get install -y npm    
Omid Ahmadyani
  • 1,430
  • 13
  • 15
5

I know it's an old question. But it keeps showing in google first position and all it says it's "install node.js". For a newbie this is not obvious, so all you have to do is go to the node.js website and search for the command for your linux distribution version or any other operating system. Here is the link: https://nodejs.org/en/download/package-manager/

In this page you have to choose your operating system and you'll find your command. Then you just log into your console as a root (using putty for instance) and execute that command.

After that, you log as normal user and go again inside your laravel application folder and run again npm install command, and it should work. Hope it helps.

gallo2000sv
  • 111
  • 1
  • 2
  • 12
3

The solution is simple.

After installing Node, you should restart your VScode and run npm install command.

Voontent
  • 719
  • 5
  • 8
  • After trying so many things (I'd already installed npm/Node), it was as simple as making sure I'd shut down VSCode and then reopening it. It worked in Terminal after then. – elarcoiris Feb 09 '23 at 07:55
3

If you already installed npm globally on your system, and you are still getting the above error message by using VSCode terminal. Just close your VSCode application and reopen again, that should resolve the issue.

an-apluss
  • 475
  • 4
  • 9
2

First You need to check the node version using terminal (not gitbash)

node --version

npm --version

if those exists, Restart your pc and check

Cheers !!

janadari ekanayaka
  • 3,742
  • 2
  • 13
  • 17
0

In my case it was entirely my fault (as usual) I was changing the system path under the environment variables, in Windows, and messed up the path for Node/NPM. So the solution is to either re-add the path for NPM, see this answer or the lazy option: re-install it which will re-add it for you.

Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38
0

maybe vscode config shell failed, you can try restart it.

JK Bi
  • 407
  • 4
  • 9