问题
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
回答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.
回答2:
Instead of using sudo
switched as root and then just run:
$ npm install -g nodemon
回答3:
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
来源:https://stackoverflow.com/questions/43334943/nodemon-installed-but-cant-be-found