I can´t install nodemon globally, “nodemon” not recognized

别等时光非礼了梦想. 提交于 2019-11-27 17:58:39

Since node prefix is not in the PATH ENV variable , any of the globally installed modules are not getting recognized.

Please try this.

Open cmd prompt

npm config get prefix

append the resulting path to PATH env variable.

Now you should be able to run nodemon from any location.


This is what i have done on my local machine


C:\>npm config get prefix
C:\Users\username\AppData\Roaming\npm

C:\>set PATH=%PATH%;C:\Users\username\AppData\Roaming\npm;

C:\>nodemon
 31 Jul 22:30:29 - [nodemon] v0.7.8
 31 Jul 22:30:29 - [nodemon] to restart at any time, enter `rs`
 31 Jul 22:30:29 - [nodemon] watching: C:\
 31 Jul 22:30:29 - [nodemon] starting `node `
 ^CTerminate batch job (Y/N)? Y
user1501382

I also got same error as you with this command:

$ sudo npm install -g nodemon

I just really switched as "root" and then just ran:

$  npm install -g nodemon

I think npm has a bug to not work with sudo, but it works fine when you are really "root".

You can add path to node packages in System Path variable. Add "C:\Users\UserName\AppData\Roaming\npm".

check out here :-

npm install -g nodemon

and then run

$nodemon server.js

Linux users: I would highly suggest not using sudo or root user to install npm packages. This could become a security problem especially on a production system. I would also suggest not trying to hack permissions as I have hosed an Ubuntu system by not reading the warning on the npmjs procedure.

It would be better to configure npm to use a folder owned by the current user. Simplest approach

wget https://raw.githubusercontent.com/pcnate/npm-configure/master/add-npm-global.sh -q -O - | bash
npm install -g nodemon

Or get the code script on github to see how it works

See details on the npmjs website

On Windows, I was having issues installing nodemon directly from the Command line. Downloaded Cygwin and I was able to npm install nodemon instantly.

Mine was I went to Control Panel and Repair the NodeJS app and tried to install again with npm install -g nodemon and now it works. Maybe you mixed up or something with Node.

Single line solution In terminal

npm install -g --force nodemon

Charitha Goonewardena

Even after adding path to System Path variable it did not work for me using nodemon. Then i used npm run serve to run the server. now it is up and running. Btw i am a windows user

This command worked for me.

If your global installation didn't work then install it in your development dependency.

npm install --save-dev nodemon

had the same problem otherwise was just working fine a day ago. Very simple fix first check if nodemon exists on your system globally or not

To check

npm list -g --depth=0

If you don't see then install it npm install -g nodemon (g stands for globally)
If you see it still doesn't work then you need to configure environment variable I use Windows OS. On Windows navigate to

Control panel>System>Advanced System Settings>Environment Variables>double-click on PATH

Now check if you have this PATH C:\Users\yourUsername\AppData\Roaming\npm
If not, you will see some existing paths, just append to it separating with semicolon. That's it! Worked for me. For me node was installed in C:..\Roaming\npm and for you if the PATH is different, you will put in whatever applcable.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!