Mohideen bin Mohammed
Mohideen bin Mohammed

Reputation: 20137

Electron JS install error - Error: EACCES: permission denied

getting error while installing ElectronJS,

Error:

Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/.electron'

command tried,

sudo npm install -g electron
sudo npm install -g electron-prebuilt

how to resolve this permission issue?

Upvotes: 10

Views: 16129

Answers (5)

jehon
jehon

Reputation: 1648

With the same message, it could also be that an eletron app is already running using that executable... So the electron binary is actually in use.

In that case, just kill the electron app currently running.

Upvotes: 0

pranav
pranav

Reputation: 83

I ran into a similar problem. I fixed it by changing folder permissions.

Check the current folder permissions of the /usr/lib/node_modules directory by running the following command:

ls -l /usr/lib | grep "node_modules

Your output will probably be:

drwxr-xr-x 3 root root {timestamp} node_modules

Change the owner of the directory to the current user by running the following command:

sudo chown -R current_username:current_username /usr/bin/node_modules

Note - Do not run sudo with any npm command! More information here.

Hope this Helps :)

Upvotes: 2

Mohideen bin Mohammed
Mohideen bin Mohammed

Reputation: 20137

Solved my issue by appending --unsafe-perm=true

command:

sudo npm install -g electron --unsafe-perm=true

unsafe-perm

Default: false if running as root, true otherwise

Type: Boolean Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

Upvotes: 11

Shobhit Sharma
Shobhit Sharma

Reputation: 493

You can try with the following command

sudo npm install -g electron --unsafe-perm=true --allow-root

i hope it will be work

Upvotes: 22

Sagar
Sagar

Reputation: 493

change npm global module default folder , follow this guide

https://docs.npmjs.com/getting-started/fixing-npm-permissions

I had a similar problem with npm on my mac and windows system and i fixed them by changing the npm default directory to another directory by following option 2 in the tutorial

Upvotes: 2

Related Questions