i can not install nodemon it has problem with npm
Vus-MacBook-Air:nodejs vuvantuu$ sudo npm install -g nodemon
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/nodemon
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/usr/local/lib/node_modules/nodemon'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/vuvantuu/.npm/_logs/2019-08-08T07_07_43_043Z-debug.log
You must be required administrative privileges to install anything, you can use
sudo npm install -g nodemon
As the error says - you don't have write access to the /usr/local/lib/node_modules
folder.
The simplest way to get rid of this error - is to run the command via sudo
sudo npm i -g nodemon
But if you don't want to run it via root
user for any reasons (eg security) you could install packages globally for a given user.
mkdir "${HOME}/.npm-packages"
npm
where to store globally installed packages npm config set prefix "${HOME}/.npm-packages"
npm
will find installed binaries and man pages Add the following to your .bashrc
/ .zshrc
:
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
NOTE: If you are running macOS, the
.bashrc
file may not yet exist, and the terminal will be obtaining its environment parameters from another file, such as.profile
or.bash_profile
. These files also reside in the user's home folder. In this case, simply adding the following line to them will instruct Terminal to also load the.bashrc
file:
source ~/.bashrc
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.