[英]Can't resolve module 'child_process'
I have an angular2 webpack project that is running in electron.我有一个在 electron 中运行的 angular2 webpack 项目。 I'm trying to use
shelljs
but webpack fails to build with the error:我正在尝试使用
shelljs
,但 webpack 无法构建并出现错误:
[0] ERROR in ./~/shelljs/src/exec.js
[0] Module not found: Error: Can't resolve 'child_process' in 'D:\Projects\angular-electron\node_modules\shelljs\src'
[0] @ ./~/shelljs/src/exec.js 6:12-36
[0] @ ./~/shelljs/src ^\.\/.*$
[0] @ ./~/shelljs/shell.js
My webpack configuration is targeting the electron-renderer
and my polyfills are using zone-node
:我的 webpack 配置针对
electron-renderer
,而我的 polyfill 正在使用zone-node
:
return {
target: 'electron-renderer', //webpack-build-common.js
...
and和
import 'zone.js/dist/zone-node'; //polyfills.ts
I have tried changing the webpack target to node
but it has no effect.我尝试将 webpack 目标更改为
node
,但没有效果。
You can see my entire webpack configuration on paste bin您可以在粘贴箱上看到我的整个 webpack 配置
Choose call exec into main.ts electron in ipcrender, work fine example:在 ipcrender 中选择 call exec 进入 main.ts electron,工作正常示例:
ipcMain.on('ipc-callchild', async (event, arg) => { const child = require('child_process').execFile; const executablePath = "C:\\Program Files (x86)\\browser.exe "; let parameters = [`${arg}`, "--kiosk", "--private-window"]; child(executablePath, parameters, function(err, data) { console.log(err) console.log(data.toString()); }); });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.