How come npm install doesn't work on git bash

前端 未结 13 1193
天涯浪人
天涯浪人 2020-12-07 19:00

I have git bash open and I type in npm install and then it returns:

bash: npm command not found

I don\'t understand, because I

相关标签:
13条回答
  • 2020-12-07 19:41

    Are you on Windows?

    If so, can you go to the Git Bash console and run:

    echo $PATH
    

    and then check if the node path(e.g. c/Program Files/node ) is there?

    If the node path is not there you'll need to add it to the system path variable.

    If it's there, can you try to run npm between double quotes?

    "npm"
    
    0 讨论(0)
  • 2020-12-07 19:41

    I had to add node path to system variable AND reboot. For some reason closing and reopening git bash was not enough

    0 讨论(0)
  • 2020-12-07 19:43

    If you are on Windows, try this: In CMD, go to folder

    C:\Program Files or (x86)\nodejs\
    

    Then try the following

    C:\Program Files\nodejs>set path=%PATH%;%CD%
    C:\Program Files\nodejs>setx path "%PATH%"
    

    It works for me!

    0 讨论(0)
  • 2020-12-07 19:43

    I had the same issue and I successed to solve it by changing the git enviornment system variable from C:\Program Files\Git\cmd to C:\Program Files\Git

    Hope that will help someone

    0 讨论(0)
  • 2020-12-07 19:43

    You need to define this #!/bin/bash start of you bash script

    #!/bin/bash
    npm install
    
    0 讨论(0)
  • 2020-12-07 19:44

    If you installed git bash first and then node.js, uninstall gitbash and keep node.js. And then re-install git bash again.

    npm --version
    node --version
    

    check version using this command

    0 讨论(0)
提交回复
热议问题