0

I've tried uninstalling and and reinstalling nodemon several times both locally and globally with:

npm install -g nodemon

(tried it both with and without sudo)

and it seems to install no problem, and gives me:

/usr/local/bin/bin/nodemon -> /usr/local/bin/lib/node_modules/nodemon/bin/nodemon.js
/usr/local/bin/lib
    └── nodemon@1.11.0 

but whenever I run

nodemon server.js

in my app, I get;

-bash: nodemon: command not found

Like I mentioned, I've tried the same process but installing locally to my app dependancies, but it doesn't seem to make a difference. What's going on here? I followed the same process on a different machine, and it worked no problem.

Googling around, I came across some posts that mentioned changing/adding the PATH? But it's not clear to me if that's or the problem or what that means.

Also, other globally installed npm modules run just fine

mrkmhny
  • 3
  • 1
  • 5
  • What happens when you type `which nodemon` ? This is what happens for me on my mac `(11:30) ~/src/CUP [work-rpt] $ which nodemon /usr/local/bin/nodemon` – Alan Apr 11 '17 at 00:41
  • Hi @Alan. When I type `which nodemon` nothing happens at all. – mrkmhny Apr 11 '17 at 00:48
  • The directory which nodemon is installed, is not in your PATH environment variable for bash. `which` shows the executables that can be found via PATH. – Alan Apr 11 '17 at 00:49
  • @Alan how do you fix that? – mrkmhny Apr 11 '17 at 00:53

3 Answers3

1

nodemon is not being found by bash.

Edit your ~/.bash_profile file and add:

PATH=$PATH:/usr/local/bin/bin/

Start a new shell to see it work, or run source ~/.bash_profile to have it apply to the current session.

Alan
  • 45,915
  • 17
  • 113
  • 134
  • Worked like a charm! – mrkmhny Apr 11 '17 at 01:01
  • Can you explain a little more what's happening here? Why is nodemon installing to a different location than other npm modules? – mrkmhny Apr 11 '17 at 01:02
  • Unsure, but seing nodemon installed in `/usr/local/bin/bin` seems like an issue. Perhaps something is amiss with your `~/.npmrc` file. – Alan Apr 11 '17 at 15:58
1

Instead of using sudo switched as root and then just run:

$  npm install -g nodemon
orvi
  • 3,142
  • 1
  • 23
  • 36
  • Thanks for the answer, but I tried installing with and without sudo. Just updated my question to clarify that. The other answer here seemed to solve the problem. – mrkmhny Apr 11 '17 at 01:03
  • did you switched as root ? – orvi Apr 11 '17 at 01:05
  • Not sure what that means. Could you explain? – mrkmhny Apr 11 '17 at 01:06
  • in your terminal type `sudo su` and access your terminal as `root` . then try the following command and let me know what happens after that. – orvi Apr 11 '17 at 01:08
0
sudo su -
export PATH=$PATH:/home/USER/npm
npm install -g --force nodemon

# THESE LINES + START FROM A NEW TERMINAL...
# IN MY CASE

npm install -g --force node-inspector

# TOO
  • Hello TheOikonomist. Your comment contains only code. It would be great if you could explain this in a few words. – astridx Dec 07 '19 at 13:04