Mathan
Mathan

Reputation: 3

How to install electron.js on linux?

I want to install electron.js on linux os. Need help to resolve the errors below:

Command to install

sudo npm i electron

Terminal output

/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js

[email protected] postinstall /usr/lib/node_modules/electron

node install.js

(node:13668) ExperimentalWarning: The fs.promises API is experimental
/usr/lib/node_modules/electron/install.js:54
  throw err
  ^

Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/electron-tmp-download-13668-1536154444869'
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!     /home/ebuilders/.npm/_logs/2018-09-05T13_34_04_997Z-debug.log

Upvotes: 0

Views: 1874

Answers (3)

Joshua
Joshua

Reputation: 5332

I've run into this error before and installing with sudo npm install -g electron --unsafe-perm=true --allow-root worked every time.

I got the command from this comment: https://github.com/electron/electron/issues/10604#issuecomment-333368230

Upvotes: 1

Sven van de Scheur
Sven van de Scheur

Reputation: 1913

This is a very typical problem in NPM environments. The root cause is that typically NPM want's to install stuff and write in a directory that the current user is not allowed to access.

There are 2 possbile solutions:

  1. Change to a more privileged user, for instance using sudo <command> or su. This is a less ideal situation as its decreases security.
  2. Reconfigure NPM/node to work within your local user account (better).

Please see the documentation on how to do this: https://docs.npmjs.com/getting-started/fixing-npm-permissions

Upvotes: 0

Shailen Naidoo
Shailen Naidoo

Reputation: 596

If i remember correctly. I used to run into this error as well. What i did was give root access to the install.js script process and that seemed to work. Try something like sudo npm i -D electronthe use of sudo with npm is not appropriate but it worked in my case

Upvotes: 0

Related Questions