Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron (Packaged): Windows 10 spawn ENOENT error #135

Open
byfareska opened this issue Apr 23, 2019 · 17 comments
Open

Electron (Packaged): Windows 10 spawn ENOENT error #135

byfareska opened this issue Apr 23, 2019 · 17 comments

Comments

@byfareska
Copy link

I'm getting something like that but on Windows 10 (on ubuntu works fine).
https://stackoverflow.com/questions/17951133/spawn-enoent-error

I've switched from 1.7.0 to 1.6.1 and it works on both OS.

@rexn8r
Copy link

rexn8r commented Jul 12, 2019

I am also having the same error after packaging the app..

I did revert back to 1.6.1 but still no luck.

Check environment variable and it has "C:\WINDOWS\system32\cmd.exe" in the path variable.

any pointer as to how to resolve this issue?

Thanks
Rex

@bencevans
Copy link
Owner

@rexn8r what do you mean by packaging the app?

@rexn8r
Copy link

rexn8r commented Jul 12, 2019

when i create app package using electron-packager and run the exe with asar file, the plugin throws the error.

If i run the electron app in development environment i.e. using npm start command from node.js command window, the plug-in works absolutely fine.

the package folder structure created by electron-packager is:

app.exe
-- resources (folder)
---|__ (under resource folder) app.asar (all the app files are packaged in it with html, javascript, node modules etc)

i unpacked the asar file and node module folder did have the screen-shot files. so its not that the packager is missing files.

any help would be appreciated.

thanks
rex

@bencevans bencevans changed the title Windows 10 spawn ENOENT error Electron: Windows 10 spawn ENOENT error Jul 12, 2019
@bencevans
Copy link
Owner

There was a fix conducted for Electron in https://github.com/bencevans/screenshot-desktop/releases/tag/v1.5.5. I'm not much doing much with Electron so this isn't a priority for me. However if you work out a fix a pull requested would be very welcome.

@ForsakenNGS
Copy link

ForsakenNGS commented Jul 21, 2019

I managed to fix this issue in my project using electron-forge by adding the "asar" => "unpack" option in the packager config:

{
  "name": "myproject",
  "version": "1.0.0",
  "description": "mydescription",
  "main": "main.js",
  "scripts": { ...  },
  "keywords": [ ...  ],
  "author": "me",
  "license": "ISC",
  "devDependencies": { ... },
  "dependencies": { ... },
  "config": {
    "forge": {
      "packagerConfig": {
        "asar": {
          "unpack": "**/node_modules/screenshot-desktop/lib/win32/{app.manifest,screenCapture_1.3.2.bat}"
        }
      },
      "makers": [ ... ]
    }
  }
}

Not sure if and how this can be applied to this projects package.json directly.

Edit: Added the missing "app.manifest" file which needs to be unpacked as well.

@bencevans
Copy link
Owner

@tance77 has submitted a PR which aims to fix this (thanks!). I don't really have anything to test it with as no longer work with any Electron apps. Would someone in this thread be up for reviewing #152?

@MetinYarci
Copy link

MetinYarci commented Sep 1, 2020

I am using electron-builder to package my application. According to electron-builder documentation, "Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set asarUnpack", however screenshot-desktop is not detected by electron-builder so I added this configuration to package.json, and the problem is solved.

  "build" {
    ...
    "asarUnpack": [
      "node_modules/screenshot-desktop/lib/win32"
    ]
  }

Very similar to the solution proposed by @ForsakenNGS

@bencevans bencevans changed the title Electron: Windows 10 spawn ENOENT error Electron (Packaged): Windows 10 spawn ENOENT error Oct 15, 2020
@bencevans
Copy link
Owner

There seem to be quite a few duplicate issues being opened up which relate to this. If someone's available to, a review of PR #152 from someone more familiar than I with Electron would be appreciated.

@tance77
Copy link

tance77 commented Oct 19, 2020

#135 (comment)
#135 (comment)

These two posts are exactly right. The .bat file needs to be unpacked along side for the packed version of the electorn app. The bat file can not be executed inside the app.asar file.

Additionally adding the files to your windows extra resources worked for me as well.

 "win": {
      "extraResources": [
        "node_modules/screenshot-desktop/lib/win32/screenCapture_1.3.2.bat",
        "node_modules/screenshot-desktop/lib/win32/app.manifest",
      ],
}

Many solutions to this problem.

The solution in #152 assumes the files to be unpacked along side the asar file

@somuelle-tmt
Copy link

somuelle-tmt commented Nov 5, 2020

I'm getting the same problems after packing with https://github.com/vercel/pkg/

Error: spawn C:\Windows\system32\cmd.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Windows\\system32\\cmd.exe',
  path: 'C:\\Windows\\system32\\cmd.exe',
  spawnargs: [
    '/d',
    '/s',
    '/c',
    '""C:\\snapshot\\prod\\node_modules\\screenshot-desktop\\lib\\win32\\screenCapture_1.3.2.bat" "C:\\TEMP\\2020105-12416-11y7u3z.wzw.jpg" "'
  ],
  cmd: '"C:\\snapshot\\prod\\node_modules\\screenshot-desktop\\lib\\win32\\screenCapture_1.3.2.bat" "C:\\TEMP\\2020105-12416-11y7u3z.wzw.jpg" '
}

As suggested by @tance77 I configured pkg to include this 2 files:

"pkg": {
    "assets": [
      "node_modules/screenshot-desktop/lib/win32/screenCapture_1.3.2.bat",
      "node_modules/screenshot-desktop/lib/win32/app.manifest"
    ]
  },

I see that they are added from the build debug log, but I'm still getting the same error.

Update:
As I learned that's a general problem with pkg as it does not allow such external processes: vercel/pkg#342

@hmake98
Copy link

hmake98 commented Nov 6, 2020

I don't understand what is the error cause? I tried the above solutions for building the application again with asar unpack but I think it's not working.

@promatik
Copy link

For me this is an issue, if I build the package without -asar it works, but all the source code is exposed 😕
When using -asar it doesn't work.

@Ciberusps
Copy link

@MetinYarci thanks a lot it works in production

@alsocodes
Copy link

alsocodes commented Jun 26, 2021

I am using electron-builder to package my application. According to electron-builder documentation, "Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set asarUnpack", however screenshot-desktop is not detected by electron-builder so I added this configuration to package.json, and the problem is solved.

  "build" {
    ...
    "asarUnpack": [
      "node_modules/screenshot-desktop/lib/win32"
    ]
  }

Very similar to the solution proposed by @ForsakenNGS

thanks.. it's work.

@urvinsoneta
Copy link

Hi
I am using this boilerplate https://github.com/michalzaq12/electron-nuxt for our app, wanted to know how and where we could add the asarunpack to explicitly unpack this module.

@si458
Copy link
Contributor

si458 commented Aug 26, 2021

im having this issue currently with https://github.com/vercel/pkg
runs fine normaly but if you bundle it, the files are there but its not able to run the .bat file on windows 👎

@si458
Copy link
Contributor

si458 commented Nov 8, 2021

please can everyone try my PR #225 i believe this will fix the issued with node bundlers like PKG 👍
EDIT: PKG also detectes the path.join and includes the bat and manifest for you 👍

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

No branches or pull requests