Issue
Hello i have this error if i try to install electron on my fedora 30
[luisjustin@localhost ~]$ sudo su
[sudo] password for luisjustin:
[root@localhost luisjustin]# npm install -g electron
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
> [email protected] postinstall /usr/lib/node_modules/electron
> node install.js
/usr/lib/node_modules/electron/install.js:49
throw err
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-05-30T01_21_04_805Z-debug.log
[root@localhost luisjustin]#
the log in this link: https://pastebin.com/q3dSCQVg
Solution
There seems to be an issue with permissions on your machine (/usr/lib
directory requires root access). What I suggest you to try is to change the default directory where NPM
is installing packages globally. Then you can try to run the installation without root access.
Try this:
On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g electron
Courtesy: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Answered By - Akshay Anurag Answer Checked By - Mary Flores (WPSolving Volunteer)