nodemon not working: -bash: nodemon: command not found

前端 未结 18 806
灰色年华
灰色年华 2021-01-30 03:45

I\'m on a Mac running El Capitan. I have node v5.6.0 and npm v3.6.0. When I try to run nodemon, I get:

-bash: nodemon: command not found

I th

相关标签:
18条回答
  • 2021-01-30 04:22

    I ran into the same problem since I had changed my global path of npm packages before.

    Here's how I fixed it :

    When I installed nodemon using : npm install nodemon -g --save , my path for the global npm packages was not present in the PATH variable .

    If you just add it to the $PATH variable it will get fixed.

    Edit the ~/.bashrc file in your home folder and add this line :-

    export PATH=$PATH:~/npm
    

    Here "npm" is the path to my global npm packages . Replace it with the global path in your system

    0 讨论(0)
  • 2021-01-30 04:22

    Just in case for those using Windows, you don't need sudo

    npm i -g nodemon
    
    0 讨论(0)
  • 2021-01-30 04:25

    FOR WINDOW USERS

    I tried every possible way but nothing worked for me.

    What worked was:- npx nodemon server

    FOLLOWING WILL BE THE OUTPUT:-

    0 讨论(0)
  • 2021-01-30 04:27

    If you want to run it locally instead of globally, you can run it from your node_modules:

    npx nodemon

    0 讨论(0)
  • 2021-01-30 04:27

    Make sure you own root directory for npm so you don't get any errors when you install global packages without using sudo.

    procedures:- in root directory

    sudo chown -R yourUsername /usr/local/lib/node_modules
    sudo chown -R yourUsername /usr/local/bin/
    sudo chown -R yourUsername /usr/local/share/
    

    So now with

    npm i npm -g 
    

    you get no errors and no use of sudo here. but if you still get errors confirm node_modules is owned again

    /usr/local/lib/

    and make sure you own everything

    ls -la

    now

    npm i -g nodemon
    

    will work!

    0 讨论(0)
  • 2021-01-30 04:27

    npx nodemon filename.js

    This will work on macOS BigSur

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