How come npm install doesn't work on git bash

前端 未结 13 1232
天涯浪人
天涯浪人 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条回答
  •  旧时难觅i
    2020-12-07 19:22

    In git bash type ...

    which npm
    

    This will tell you where npm is installed.

    Now, I'm assuming this will give you nothing since it seems npm is not on your system PATH variable. The PATH variable defines where Windows looks for commands.

    Go into your control panel and click system advanced settings and add the directory containing npm to your path.

    If you dont know where it is then open a normal windows console and type ...

    where npm
    

    This will show you where it is so you can add it to your path.

    Then close your git bash terminal and reopen it and npm should work.

    PS if you want to check the PATH variable inside git bash, make sure the correct npm folder is on the PATH then just type ...

    echo $PATH
    

    PPS Another tip - you can tweak the PATH for git bash only via your .bashrc OR .bash_profile files.

提交回复
热议问题