I encountered some problems while trying to install nodemon with the command line of 'npm install -g nodemon'
as shown in the image below.

- 430
- 4
- 15

- 55
- 8
-
Right click ====> open as Administrator – Chris Aug 07 '17 at 13:35
-
Its says it in the log. You do not have access to `/usr`. On Linux try: `sudo npm i -g nodemon` – Dániel Emőd Kovács Aug 07 '17 at 13:35
3 Answers
As the error suggests you need to run npm install -g with root privileges.
either open an Administration console in Windows, or use sudo in Linux:
sudo npm install -g nodemon
If you want to avoid that, you can look into using NVM, which can provide a global node_modules that does not depend on root privileges.

- 588
- 1
- 4
- 16
You should never need to run npm install -g
with root privileges - if you are getting permission errors then this means that npm has been installed incorrectly. The npm website provides fairly comprehensive documentation on how to fix this - https://docs.npmjs.com/getting-started/fixing-npm-permissions
The best options are to either use a package manager to install npm, such as Homebrew on MacOS. Node Version Manager (NVM) can also ease the process, as well as providing support for using different node versions. Alternatively you can either change the ownership of /usr/local
so that your current user has permissions there, or change the folder used by npm to one owner by the current user.

- 4,009
- 1
- 16
- 34
-
Most linux package managers will install node this way. Since -g is a system-wide change, then running it with root is not necessarily a bad thing. – Alex Dow Aug 07 '17 at 13:48
-
This is the permanent solution that would help instead of adding sudo every time. Sometimes even sudo doesn't work if node is downloaded incorrectly. Another link, https://github.com/nvm-sh/nvm#installation-and-update, shows how to install NVM and remove the currently installed version of node and re-download it with nvm to fix this issue permanently. – Stephen Romero Sep 05 '19 at 17:57
write on your terminal or cmd :
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
enter your password of PC : then try
npm install -g nodemon
Hope the problem is solvedSee the solution in screen shot .