screenshot-desktop
screenshot-desktop copied to clipboard
Electron (Packaged): Windows 10 spawn ENOENT error
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.
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
@rexn8r what do you mean by packaging the app?
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
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.
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.
@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?
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
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.
https://github.com/bencevans/screenshot-desktop/issues/135#issuecomment-513575121 https://github.com/bencevans/screenshot-desktop/issues/135#issuecomment-685074823
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
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: https://github.com/vercel/pkg/issues/342
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.
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.
@MetinYarci thanks a lot it works in production
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.
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.
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 π
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 π