1

I have been trying to install electron using npm on high sierra and I am unable to do so, sudo or changing folder permission, nothing seems to work.

I did see this error on several posts but most of them point to using the correct node version. Some links I checked: 1 2

I was on version 9.2.1 but switched to version 8.2.1 based on what I saw in electron.

Below is the screenshot of the error: enter image description here

Is this because for some reason I am forbidden from adding certain files to my root? I have tis doubt because of late I am having a lot of hassle installing any software. Is there a way to get rid of this problem for good?

Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
theusual
  • 741
  • 2
  • 11
  • 24
  • Why would you want to install Electron globally? Installing as a dev dependency to a local project is recommended by the authors – Patrick Hund Jan 07 '18 at 20:16
  • 1
    @PatrickHund I tried doing that initially, got the same error. I was trying this command: npm install electron --save-dev --save-exact and saw the same error. – theusual Jan 07 '18 at 20:21
  • I checked the same problem [here](https://github.com/npm/npm/issues/17268). But that solution does not work for me – theusual Jan 08 '18 at 14:55
  • 1
    Did you follow these instructions? https://github.com/electron/electron/blob/master/docs/tutorial/installation.md#troubleshooting – Patrick Hund Jan 08 '18 at 19:46
  • Omg yes this did it! I did not achieve this in 1 step though: – theusual Jan 08 '18 at 19:56
  • Step 1: npm install --platform=linux electron . This gave an error (SyntaxError: Use of const in strict mode.) I was familiar with a hack to resolve this error. Step 2: nvm install node --reinstall-packages-from=node. Step 3: npm install --platform=linux electron. Thats it. Thanks a lot @PatrickHund – theusual Jan 08 '18 at 20:09
  • Okay for those facing a problem with installation using npm, I found a way to install using homebrew - works like a charm! Link is : http://macappstore.org/electron/ – theusual Jan 10 '18 at 03:03

1 Answers1

0

I had faced same problem, the reason behind is the installer you use to install your node either brew or nvm doesn't has root access privileges.

brew :- By default brew doen't have root access permission to install applications.

nvm :- same case for nvm, Installed Node doen't have root access permission to install libs.

First option, Install nodejs manually by downloading from server, install it and then try to install electron by using following command

npm install electron --save-dev 

or

sudo npm install electron --save-dev 

Second option, give the nvm or brew root privileges

Manshu Sharma
  • 83
  • 1
  • 8