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

199,356

Solution 1

I tried the following, and none worked:

npm uninstall nodemon

sudo npm uninstall -g nodemon

What did work was:

sudo npm install -g --force nodemon

Solution 2

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

npx nodemon

Solution 3

From you own project.

npx nodemon [your-app.js]

With a local installation, nodemon will not be available in your system path. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as npm start) or using npx nodemon.

OR

Create a simple symbolik link

ln -s /Users/YourUsername/.npm-global/bin/nodemon /usr/local/bin

ln -s [from: where is you install 'nodemon'] [to: folder where are general module for node]

node : v12.1.0

npm : 6.9.0

Solution 4

I'm using macOS/Linux, the solution that works for me is

npx nodemon index.js 

I have tried every possibility, like uninstalling and installing nodemon, installing nodemon globally. restart the terminal, but it won't work.

don't try such things to waste your time.

Solution 5

in Windows OS run:

npx nodemon server.js

or add in package.json config:

...
"scripts": {
    "dev": "npx nodemon server.js"
  },
...

then run:

npm run dev
Share:
199,356

Related videos on Youtube

Brian O'Neill
Author by

Brian O'Neill

UX designer and developer, San Francisco Bay Area

Updated on July 08, 2022

Comments

  • Brian O'Neill
    Brian O'Neill almost 2 years

    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 thought this may mean that I didn't have nodemon installed, so when I tried to install it using...

    sudo npm install -g nodemon
    

    ...I get this:

    npm ERR! Darwin 15.2.0
    npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g"     "nodemon"
    npm ERR! node v5.6.0
    npm ERR! npm  v3.6.0
    npm ERR! path /usr/local/bin/nodemon
    npm ERR! code EEXIST
    
    npm ERR! Refusing to delete /usr/local/bin/nodemon: ../lib/node_modules/nodemon/nodemon.js symlink target is not controlled by         npm /usr/local
    npm ERR! File exists: /usr/local/bin/nodemon
    npm ERR! Move it away, and try again.
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     /Users/brianeoneill/npm-debug.log
    

    If it makes a difference, I'm trying to run nodemon on a project that uses Express v4.13.1

    Thanks for any help you can offer!

    • Sterling Archer
      Sterling Archer about 8 years
      Have you uninstalled nodemon before trying to install it again globally? npm uninstall nodemon
    • Brian O'Neill
      Brian O'Neill about 8 years
      I tried that and it didn't work. However, I just tried sudo npm install -g --force nodemon, and that seemed to do the trick. Thanks for your help!!!!!
    • Sergey Andreev
      Sergey Andreev over 6 years
      May be my solution helps you ;) stackoverflow.com/questions/46505121/…
  • Jinesh
    Jinesh about 8 years
    watch the following video from official docs site docs.npmjs.com/getting-started/fixing-npm-permissions . Will give you better insight about the issue.
  • Russo
    Russo over 5 years
    or add this line if you use yarn: export PATH="$(yarn global bin):$PATH"
  • MJ Montes
    MJ Montes almost 5 years
    --save is no longer needed after npm v5
  • jerseyetr
    jerseyetr almost 5 years
    EDIT: sadly i have to use this command each and everytime i want to run my program instead of it installing nodemon locally.
  • Dostonbek Oripjonov
    Dostonbek Oripjonov over 4 years
    recommendation to delete package : 1 - Remove line from package.json 2 - and type this command " node prone "
  • Didierh
    Didierh almost 3 years
    This works on Mac OSx like charm! Thank you!
  • Mohammad Afzali
    Mohammad Afzali over 2 years
    Worked like a charm! Thanks. (I use ubuntu 20.04)
  • Janib Soomro
    Janib Soomro over 2 years
    Worked for me as well. Thanks.
  • Atif Mahmood
    Atif Mahmood almost 2 years
    solved thanks for complete solution