简体   繁体   中英

Problems of installing npm nodemon

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

控制台输出

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM