Just recently I bumped into the problem of installing Electron on my system globally, and it seems very much, like I am not the only one out there, who encounters the same problem.
Usually, what you would do, to install a node package globally, e.g. Electron, you would type something like
sudo npm install -g electron@latest
Unfortunately this command spits out an error, sounding similar to this:
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js > email@example.com 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! firstname.lastname@example.org postinstall: `node install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the email@example.com 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-01-20T08_50_17_638Z-debug.log
The error basically says, that the install script ‘install.js’ does not have sufficient permissions to make changes in the ‘/usr/lib/node_modules/’ folder.
To solve the missing permission issue from above, I found to use some additional parameters in the install command. This should allow you to install the npm electron package globally on your system:
sudo npm install -g electron@latest --unsafe-perm=true --allow-root
Even tho this allows you to bypass the issue, it is not the recommended way to install npm packages!