npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir'/usr/local/lib/node_modules/nodemon'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/nodemon'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
Looks like the problem is with the package generator-karma, not sure if this is the problem or not.
Can anyone show me what i need to do to get this installing correctly.
Thanks Sanil
CodePudding user response:
This looks like a permissions issue in your home directory. To reclaim ownership of the node_modules directory execute:
sudo chown -R $(whoami) ~/node_modules
CodePudding user response:
Node.js error EACCES
means you don't have access to the path it's specifying. In this case, /usr/local/lib/...
is owned by the root
user. See the command output here:
$ ls -l /usr/local/lib
total 12
drwxr-xr-x 4 root root 4096 Apr 7 23:45 node_modules
Nobody but root is allowed to write to the node_modules
folder. This can be solved by prefixing your npm command with sudo
to run the command as root.
See other: Understanding Linux File Permissions - Linuxize
CodePudding user response:
I believe you're trying to install a global package on your system by using npm install -g nodemon
, then got permission denied, which is shown in error message.
You can't install a global package without root permission. If you want to do so, just execute it with root permission, like using sudo: sudo npm i -g nodemon
or switch to root then execute again.