2
votes

Using Windows 10, Node v12.13.0 and NPM v6.12.0 along with electron and I receive the following below when I run npm run package-win to build my exe, I've never experienced something like this before.

EPERM: operation not permitted, lstat 'C:\Users\devbox\AppData\Local\Temp\electron-download-sOTFU2\electron-v1.8.8-win32-ia32.zip'

Things I have tried:

Edited my .npmrc file which has the following: strict-ssl=false registry=http://registry.npmjs.org/ Run my cmd as administrator (Administrator: Command Prompt) Restarted my computer and flushed npm cache Disabled antivirus then discovered electron-builder

I then installed electron-builder but when running electron-builder -w I run into the following below:

• cannot move downloaded into final location (another process downloaded faster?) path=C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4 tempFile=C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\527857811 error=rename C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\527857811 C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4: Access is denied. ⨯ ENOENT: no such file or directory, copyfile 'C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4\elevate.exe' -> 'C:\Users\devbox\Desktop\electron\boxapp\dist\win-unpacked\resources\elevate.exe' stackTrace= Error: ENOENT: no such file or directory, copyfile 'C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4\elevate.exe' -> 'C:\Users\devbox\Desktop\electron\boxapp\dist\win-unpacked\resources\elevate.exe' at processImmediate (internal/timers.js:439:21)

I am not able to make a folder in the specified directory above due to IT restrictions... is there a way I can specify another folder/path in my package.json file in hopes of getting around this block/error? I do have an exe that is working but this error in the build process has me concerned that something is not 100%. Can anyone share some suggestions or workarounds?

3

3 Answers

4
votes

The solution in this particular case was to go to the folder referenced below C:\Users\devbox\AppData\Local\electron-builder\Cache\nsis\ Then rename one of the temporary folders ( I had many after a few attempts from above) that was downloaded but not renamed with the necessary contents inside to nsis-3.0.4 Of course ensure that the contents are actually inside, in this case they were. Then run electron-builder and the error will no longer appear and you will see a nsis-resources-3.4.1 folder in the same path as above.

0
votes

I also encountered this issue running electron-builder in a CI context. What solved it for me was to specify the cache directory within electron-builder's config in package.json.

For example:

{
    "name": "...",
    "dependencies": [ ... ],
    "build": {
        "appId": "...",
        "files": [ ... ],
        "electronDownload": {
          "cache": "./.electron-cache"
        }
    }
}

– Which downloads electron into a .electron-cache directory local to the project. I added this directory to my .gitignore list too.

More info in the electron-builder docs.

0
votes

I was having the same problem. Apparently electron-builder does blind copy without checking if directories in target path exist and doesn't even try to create them, which raises the exception. I created all the non-existing directories in target path [{YourTargetPath}/resources] so that it can copy and it worked.