node -v
v8.9.4
npm -v
5.6.0
sudo npm install electron -g
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
> electron@1.7.11 postinstall /usr/lib/node_modules/electron
> node install.js
/usr/lib/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/electron-tmp-download-4860-1517066058438'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.7.11 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron@1.7.11 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm install -g electron --unsafe-perm=true --allow-root
@wan-ghuan try this sudo npm install -g electron --unsafe-perm=true.
Hope that helped
sudo npm install -g electron --unsafe-perm=true --allow-root This helped to solve the issue, thanks
You need to set the permissions of
/usr/lib/node_modulesto be writable by your user.For more info on these NPM errors please see: Troubleshooting Installation
I still have this issue and the command posted by @obendesmond also worked. What I find interesting is that I have had that issue on my Ubuntu 18.04 notebook, my Macbook Pro and two newly-created Ubuntu AWS instances, completely different environments, which makes me think a huge portion of the users may be facing this issue as well. Obviously I may be wrong, but here I leave the question: isn’t the portion of the environments where the unsafe-perm switcher too expressive enough to make a point on the documentation about it (to save new users from some Googling)? Or actually the environments where this is required are inexpressive (and I’m just out of luck)?