0
votes

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

2
sudo npm i -g nodemon. Or if you don't want to do it via root user - check npm install global without sudoIhor Sakailiuk
you could also keep nodemon locally in your project, and access it by npm run scriptSatnam Sandhu

2 Answers

0
votes

You must be required administrative privileges to install anything, you can use

sudo npm install -g nodemon

0
votes

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 (e.g security) you could install packages globally for a given user.

  1. Create a directory for global packages
mkdir "${HOME}/.npm-packages"
  1. Tell npm where to store globally installed packages
npm config set prefix "${HOME}/.npm-packages"
  1. Ensure 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