-
Notifications
You must be signed in to change notification settings - Fork 52
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
[Windows] Electron-Builder - Cannot find CommandCam.exe #59
Comments
Inside your builder configuration add nodeIntegration: true,
externals: ['node-webcam'],
nodeModulesPath: ['node_modules'], Then you can add a hook to //Apply patch to fix electron-builder issue
onNodeModuleFile(file) {
if (!file.includes('node-webcam')) return;
if (file.includes('\\node-webcam\\src\\webcams\\WindowsWebcam.js')) {
let str = fs.readFileSync(file, 'utf-8');
str = str.replace(
'WindowsWebcam.prototype.generateSh',
`WindowsWebcam.prototype.bin = WindowsWebcam.prototype.bin.includes('.asar.unpacked') ? WindowsWebcam.prototype.bin : WindowsWebcam.prototype.bin.replace('app.asar', 'app.asar.unpacked').replace(/.unpacked.unpacked/g, '.unpacked');\r\nWindowsWebcam.prototype.generateSh`
);
fs.writeFileSync(file, str, 'utf-8');
console.log(
'✔️Applied patch to node-webcam file ""./node_modules/src/webcams/WindowsWebcam.js'
);
}
} All put together (in my case in pluginOptions: {
electronBuilder: {
nodeIntegration: true,
externals: ['pdf-to-printer', 'node-webcam'],
nodeModulesPath: ['node_modules'],
builderOptions: {
//Apply patch to fix electron-builder issue
onNodeModuleFile(file) {
if (!file.includes('node-webcam')) return;
if (file.includes('\\node-webcam\\src\\webcams\\WindowsWebcam.js')) {
let str = fs.readFileSync(file, 'utf-8');
str = str.replace(
'WindowsWebcam.prototype.generateSh',
`WindowsWebcam.prototype.bin = WindowsWebcam.prototype.bin.includes('.asar.unpacked') ? WindowsWebcam.prototype.bin : WindowsWebcam.prototype.bin.replace('app.asar', 'app.asar.unpacked').replace(/.unpacked.unpacked/g, '.unpacked');\r\nWindowsWebcam.prototype.generateSh`
);
fs.writeFileSync(file, str, 'utf-8');
console.log(
'✔️Applied patch to node-webcam file "./node_modules/src/webcams/WindowsWebcam.js"'
);
}
}
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On windows, after packaged with electron builder I get the error
The text was updated successfully, but these errors were encountered: