Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Installing globally on darwin fails with EACCESS #48

Closed
justinmchase opened this issue Aug 6, 2015 · 17 comments
Closed

Installing globally on darwin fails with EACCESS #48

justinmchase opened this issue Aug 6, 2015 · 17 comments

Comments

@justinmchase
Copy link

We've been burned by this a couple of times but to install globally you have to do sudo npm install electron-prebuilt -g and it seems like it's attempting to copy a temp file from a root folder into a user folder that it doesn't have access to.

The work around is to install electron-prebuilt locally once, npm install electron-prebuilt to get the binary into the user folder cache, then install globally.

I just wanted to point this out, it would be nice if this error didn't happen, it's not blocking me though.

@italodeverdade
Copy link

I have the same problem, i'm running with sudo command but a received EACCES.

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

> [email protected] postinstall /usr/local/lib/node_modules/electron-prebuilt
> node install.js

Downloading electron-v0.32.1-darwin-x64.zip
[============================================>] 100.0% of 35.97 MB (866.73 kB/s)

/usr/local/lib/node_modules/electron-prebuilt/install.js:15
throw err
    ^
Error: EACCES, rename '/usr/local/lib/node_modules/electron-prebuilt/electron-tmp-download-10443-   1441832684729/electron-v0.32.1-darwin-x64.zip'

@x-ji
Copy link

x-ji commented Sep 12, 2015

Any update on this? I even totally reinstalled node but the problem seems to remain.

@max-mapper
Copy link
Contributor

This is a hard one to reproduce, as it seems to only affect a very small number of OS X users.

What happens when you install, in a nutshell:

You can run it with DEBUG=electron-download npm i electron-prebuilt -g to see the exact names of these folders. Then you can poke around and look at the ownership on those folders to figure out whats going on.

@x-ji
Copy link

x-ji commented Sep 12, 2015

Yeah I guess somehow the permissions are messed up and I'm doing chmod. It seems that if I chmod not only for the user myself but also for group and others it works. Maybe others could also give it a try?

@justinmchase
Copy link
Author

I'm not a big mac guy so I'm not sure what's wrong with my environment but I'll try to add some context to see if anything helps.

Someone game me their old mac to use. There was already a main account on the mac, I was added as a user later and set as an administrator. I can sudo. Whenever I install an npm package globally I have to sudo (e.g. sudo npm install electron-prebuilt -g). Is that normal? Maybe that's the problem?

Here is the error with the debugging information you asked for:

Macintosh:revolve justin$ sudo DEBUG=electron-download npm i electron-prebuilt -g
/usr/local/bin/electron -> /usr/local/lib/node_modules/electron-prebuilt/cli.js

> [email protected] postinstall /usr/local/lib/node_modules/electron-prebuilt
> node install.js

  electron-download info +0ms { cache: '/Users/justin/.electron',
  filename: 'electron-v0.32.2-darwin-x64.zip',
  url: 'https://github.com/atom/electron/releases/download/v0.32.2/electron-v0.32.2-darwin-x64.zip' }
  electron-download creating cache/tmp dirs +22ms
  electron-download downloading zip +14ms https://github.com/atom/electron/releases/download/v0.32.2/electron-v0.32.2-darwin-x64.zip to /usr/local/lib/node_modules/electron-prebuilt/electron-tmp-download-642-1442250415501
Downloading electron-v0.32.2-darwin-x64.zip
[============================================>] 100.0% of 35.97 MB (5.33 MB/s)
  electron-download moving zip to +8s /Users/justin/.electron/electron-v0.32.2-darwin-x64.zip
/usr/local/lib/node_modules/electron-prebuilt/install.js:15
  throw err
        ^
Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/electron-prebuilt/electron-tmp-download-642-1442250415501/electron-v0.32.2-darwin-x64.zip' -> '/Users/justin/.electron/electron-v0.32.2-darwin-x64.zip'
    at Error (native)

Info on the directories mentioned here:

Macintosh:revolve justin$ ls -la /Users/justin/.electron
drwxr-xr-x  10 justin  staff       340 Aug 26 16:25 .

Surprisingly though:

Macintosh:revolve justin$ ls -la /usr/local/lib/node_modules/electron-prebuilt
ls: /usr/local/lib/node_modules/electron-prebuilt: No such file or directory

Maybe node is cleaning it up after the failure, I'm not sure. But everthing in that node_modules folder is owned by nobody or root.

@kmsheng
Copy link

kmsheng commented Oct 2, 2015

I solved this problem by removing sudo

@justinmchase
Copy link
Author

This was fixed at some point.

@linkSwr
Copy link

linkSwr commented Mar 17, 2016

I solved by npm install locally ;then, npm global intall again

@ghost
Copy link

ghost commented Mar 17, 2016

had the same problem.

Solved with this:
rm -Rf ~/.electron/

then it worked
sudo npm install electron-prebuilt -g

@jctovar
Copy link

jctovar commented Mar 31, 2016

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

The error is on "El Capitan" OSX 10.11.4

@bumpmann
Copy link

Thanks jctovar, that worked for me. This should be fixed or documented somewhere

@chrischang
Copy link

Thank you ariu! It worked :)

@AshrafBasry
Copy link

AshrafBasry commented Jul 3, 2017

sudo npm install -g electron
/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js

[email protected] postinstall /usr/local/lib/node_modules/electron
node install.js

/usr/local/lib/node_modules/electron/install.js:47
throw err
^

Error: EACCES: permission denied, mkdir '/usr/local/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! /home/zero/.npm/_logs/2017-07-03T02_47_14_697Z-debug.log

Ubuntu 17.04

@Borkes
Copy link

Borkes commented Jul 4, 2017

#139 you can look this problem, I fixed it use
sudo npm install -g electron --unsafe-perm=true --allow-root @AshrafBasry

@gitkv
Copy link

gitkv commented Sep 25, 2017

Ебаное говно!

#139 you can look this problem, I fixed it use
sudo npm install -g electron --unsafe-perm=true --allow-root @AshrafBasry

/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:48
  throw err
  ^

Error: Failed to find Electron v1.7.8 for linux-x64 at https://github.com/electron/electron/releases/download/v1.7.8/electron-v1.7.8-linux-x64.zip
    at Request.<anonymous> (/usr/lib/node_modules/electron/node_modules/nugget/index.js:169:61)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Request.onRequestResponse (/usr/lib/node_modules/electron/node_modules/request/request.js:1068:10)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
    at TLSSocket.socketOnData (_http_client.js:454:20)
    at emitOne (events.js:115:13)
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.

@gflohr
Copy link

gflohr commented Mar 19, 2019

As pointed out above sudo npm install -g electron --unsafe-perm=true --allow-root most likely fixes the problem. Alternatively, try yarn instead:

sudo yarn add global electron

@justinmchase
Copy link
Author

justinmchase commented Mar 21, 2019

I just want to add that you probably no longer need to, and probably should not, install any packages globally ever again. Always prefer local install only.

To use a locally installed command use package.scripts or npx.

For both cases:

npm install electron

Then invoking it from npm, add to your package.json

{
  "scripts": {
    "electron": "electron $*"
  }
}

then

npm run electron

Or with npx:

npx electron

Avoid global installs as it will affect all repositories and you can have confusing version conflicts and you'll have to manually update it constantly if other people update the version in the repo. There is no good reason to do global installs ever again, as far as I know.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests