Node JS NPM modules installed but command not recognized

前端 未结 6 792
我寻月下人不归
我寻月下人不归 2020-12-12 20:21

Node JS and NPM was working well before. Recently I have re-installed the Node JS, NPM and the problem started. After I install a module like example npm install -g bo

6条回答
  •  悲哀的现实
    2020-12-12 21:05

    I had the same problem as well but installed it globally so the other answers didn't work.

    The nodeJS install may not have added npm to your PATH so it's not recognised globally.

    Firstly: To figure out if you installed globally or for current user

    If there is an npm folder at "C:\Users(your username)\AppData\Roaming\npm" you've installed it for the current user

    If there is an npm folder at "C:\Program Files\nodejs\node_modules\npm" or "C:\Program Files(x86)\nodejs\node_modules\npm" you've installed it globally for all users to access

    Secondly: To add it to the Path

    1. Right click My Computer
    2. Click on properties down the bottom
    3. Click on Advanced System Settings in the left bar
    4. Click on Environment Variables down the bottom

    Now depending whether you installed globally or for the current user will determine which PATH variable you are updating and with what path location

    Local

    1. Double click on PATH under 'user variables' section
    2. Add "C:\Users(your username)\AppData\Roaming\npm" without the quotes

    Global

    1. Double click on PATH under 'user variables' section
    2. Add "C:\Program Files\nodejs" without the quotes (or with (x86))

    Finally

    Close all terminals or programs that aren't able to find npm and open them up again

提交回复
热议问题