electron: Unable to install Electron version >=7: EPERM: operation not permitted

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • electron@7.0.0 (any version > 6)
  • Operating System:
    • Windows 10 May 2019 Update
  • Last Known Working Electron version:
    • electron@6.0.8 (in fact any version <= 6)

Expected Behavior

Should download and install fine.

Actual Behavior

Download fails with permission denied error.

To Reproduce

npm install electron on windows

Screenshots

Capture Capture1

Additional Information

I don’t know. 😦 Looks like the download method changed in the newer version which somehow does not work for me.

So far I have tried these options:

  • Disabled Windows defender
  • Tried recreating temp folder
  • Tried changing path of temp folder (even changed drive)
  • Adding everyone to the security of the temp folder
  • Updating npm
  • Running CMD as Administrator
  • Making sure that run nodejs always run as administrator

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 29

Most upvoted comments

Workaround:

  1. start installer normally with npm install electron, installation fails with EPERM error, but creates node_modules folder
  2. create folder \dist in node_modules\electron
  3. download release package directly from https://github.com/electron/electron/releases
  4. unzip release package to node_modules\electron\dist
  5. create path.txt in node_modules\electron directory, add text: electron.exe

From this point it should work. If you re-run the installer the dist folder and path.txt will be deleted.

Colleague fixed it by edit .\node_modules@electron\get\dist\cjs\artifact-utils.js line 38 :

function getArtifactRemoteURL(details) {
    var opts = details.mirrorOptions || {};
    var base = mirrorVar('mirror', opts, BASE_URL);
    if (details.version.includes('nightly')) {
        base = mirrorVar('nightly_mirror', opts, NIGHTLY_BASE_URL);
    }
    var path = mirrorVar('customDir', opts, details.version);
   // add this line	
   path = path.substr(1);
    var file = mirrorVar('customFilename', opts, getArtifactFileName(details));
    return "" + base + path + "/" + file;
}

I had same problem, but on my environment, Remove line below from .npmrc ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/ will solve this problem.

Was a coporate proxy problem here… To fully configure the proxy do:

export ELECTRON_GET_USE_PROXY=1
export GLOBAL_AGENT_HTTP_PROXY=http://our.proxy.com/
export GLOBAL_AGENT_HTTPS_PROXY=http://our.proxy.com/
npm i -D electron

Had the same problem and did some debugging. @electron/get handles electron downloads starting from electron 7.

Turns out you need to set ELECTRON_GET_USE_PROXY. Then @electron/get uses global-agent as proxy lib. global-agent in turn uses the env variable GLOBAL_AGENT_HTTP_PROXY to determine the proxy address.

Setting both resolved the issue for me!

PS D:\liuyunqing\project\JavaScript\WebStorm\6> npm i -D electron@latest

> electron@7.0.0 postinstall D:\liuyunqing\project\JavaScript\WebStorm\6\node_modules\electron
> node install.js

(node:18680) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, lstat 'C:\Users\liuyu\AppData\Local\Temp\electron-download-ZCtMMr\electron-v7.0.0-win32-x64.zip'
(node:18680) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18680) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

yes,now i have to install electron@6.1.3 instead