Everytime I try to install something with npm (in this case electron-packager) I run into this error. How can I solve this issue?
I have already tried to give me access by changing the permissions on.npm via chmod, but it didn't work and I also tried it with another node version (installed via nvm: node -v 12.1.0; npm -v 6.9.0) and it didn`t work as well.
$ npm install electron-packager --save-dev
npm ERR! path /Users/felixmoser/.npm/_cacache/index-v5/15/a0
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'
npm ERR! [OperationalError: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'] {
npm ERR! cause: [Error: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: 'Error: EACCES: permission denied, mkdir ' +
npm ERR! "'/Users/felixmoser/.npm/_cacache/index-v5/15/a0'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/Users/felixmoser/.npm/_cacache/index-v5/15/a0',
npm ERR! parent: 'electron-packager'
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 (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/felixmoser/.npm/_logs/2019-05-01T14_11_08_530Z-debug.log
I actually don't know what else I should try now and hope, that you guys can help me solve this problem!
change the ownership of .npm folder, In my case I couldn't figure out the solution so I used
sudo chown -R $(whoami) ~/.npm
Just change the owner of ~/.npm
folder to yourself:
sudo chown -R felixmoser ~/.npm
You'll need to enter your password for calling sudo
.
There is also a similar problem with permissions when trying to install packages globally with --global
or -g
. I know it's not your current problem, but I want to add it here because people googling the EACCESS when doing a global install might reach this question as well.
Some people change the system folder privileges allowing non-root users writing in system folder, however here is what they recommend in the documentation:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally/
Back up your computer (including it here because documentation mentions is too, but it feels to me overly cautious)
Then execute:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Edit your ~/.profile :
export PATH=~/.npm-global/bin:$PATH
Then invoke it with
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g jshint
Or instead of modifying ~/.profile just use the corresponding ENV variable (but to make it pernament you would have to modify the profile file anyway)
NPM_CONFIG_PREFIX=~/.npm-global
Simply add sudo
So instead of npm install electron-packager --save-dev
Let it be sudo npm install electron-packager --save-dev
Please consider running the instructions at least inside the user's location, for example:
/home/myuser/
express HelloWorld --view=pug
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.