Search code examples
node.jsnpmelectronelectron-packagerelectron-forge

"Windows cannot access the specified..." .Exe's made by electron-packager nor electron-forge


I'm on a Win 8.1 x64 machine. When I try to run the generated Windows binaries, I get a Windows error message.

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.

What I've tried:

  • I've checked permissions, my UAC account already had full control.
  • I switched from using electron-forge make to electron-packager [folder] [projectTitle] --platform=win32 --arch=x64 (same error)
  • I updated npm, electron, electron-packager, electron-forge, and at one point had to install locally a series of packages and juggle some things from dep to devdep
  • In particular, I had to move electron dependency to the devdeps section in order to satisfy electron-forge
  • Copied the .exe to a different folder e.g. e:\ and tried running it from there (same error)
  • Running as Administrator (same error)
  • Changed electronPackagerConfig.packageManager to false per the recommended workaround for this recent known issue about pruning failing (not related to this problem, but it's a factor in play)
  • Opened both .exe's in 7zip and noticed that the one generated by electron-forge didn't have much in it. This may be nothing or it may correlate with the console output for that command, below.

My Goal:

This is my first electron app (I come from a web background). I'm doing this build as a sanity check before I start significantly integrating my app with electron's API.

Output of commands

electron-forge make

$ electron-forge make
We need to package your application before we can make it
[BABEL] Note: The code generator has deoptimised the styling of "E:/cygwin64/tmp/electron-packager/win32-x64/fictionDB-win32-x64/resources/app/.tmp/public/js/ckeditor/ckeditor.js" as it exceeds the max of "500KB".
[BABEL] Note: The code generator has deoptimised the styling of "E:/cygwin64/tmp/electron-packager/win32-x64/fictionDB-win32-x64/resources/app/.tmp/public/js/jquery-ui/jquery-ui.js" as it exceeds the max of "500KB".
Making for the following targets:

$

Notice how it seems to just cut off there? I wouldn't know but I'm guessing that's odd.

electron-packager . fictionDB --platform=win32 --arch=x64

$ electron-packager . fictionDB --platform=win32 --arch=x64
Downloading tmp-50796-1-SHASUMS256.txt-7.1.7
[============================================>] 100.0% of 5.56 kB (5.56 kB/s)
Packaging app for platform win32 x64 using electron v7.1.7
Wrote new app to E:\xxx\Documents\src\js_src\Projects\testbed6\fictionDB-win32-x64

$

package.json

{
  "name": "fictionDB",
  "private": false,
  "version": "0.0.0",
  "description": "A way for fiction writers to plan & organize",
  "keywords": [
    "organize",
    "database",
    "fiction",
    "novel",
    "stories",
    "characters",
    "events",
    "locations",
    "settings"
  ],
  "dependencies": {
    "@sailshq/connect-redis": "^3.2.1",
    "@sailshq/lodash": "^3.10.3",
    "@sailshq/socket.io-redis": "^5.2.0",
    "acorn": "^7.1.0",
    "ckeditor": "^4.12.1",
    "connect-redis": "^4.0.3",
    "electron-compile": "^6.4.4",
    "electron-squirrel-startup": "^1.0.0",
    "grunt": "^1.0.4",
    "jquery": "^3.4.1",
    "jquery-ui-dist": "^1.12.1",
    "lodash": "^4.17.15",
    "request": "^2.88.0",
    "sails": "^1.2.3",
    "sails-hook-grunt": "^4.0.1",
    "sails-hook-orm": "^2.1.1",
    "sails-hook-sockets": "^2.0.0",
    "socket.io-redis": "^5.2.0"
  },
  "devDependencies": {
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "electron": "^7.1.7",
    "electron-forge": "^5.2.4",
    "electron-prebuilt-compile": "4.0.0",
    "eslint": "5.16.0"
  },
  "scripts": {
    "start": "electron-forge start",
    "test": "npm run lint && npm run custom-tests && echo 'Done.'",
    "lint": "./node_modules/eslint/bin/eslint.js . --max-warnings=0 --report-unused-disable-directives && echo '✔  Your .js files look good.'",
    "custom-tests": "echo \"(No other custom tests yet.)\" && echo",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },
  "main": "app/launch.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/NathanHawks/FictionDB.git"
  },
  "author": "Nathan Hawks",
  "license": "MIT",
  "engines": {
    "node": "^8.9"
  },
  "config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "packageManager": false
      },
      "electronWinstallerConfig": {
        "name": "fictionDB"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "fictionDB"
      }
    }
  }
}


Solution

  • I forgot to turn off antivirus shields. That fixed it. (For the permanent solution, I then added a security exception in my antivirus app's settings.)

    As a note of interest, the version made by electron-forge didn't work:

    screenshot of javascript error: "Asked for c:\yadda\app.js but it was not precompiled!

    However, the one made by electron-packager alone, worked fine.