简体   繁体   English

无法解析模块“child_process”

[英]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.

相关问题 无法解析模块xmlhttprequest中的“ child_process” - Can't Resolve “child_process” in module xmlhttprequest 找不到模块:无法解析“ child_process” - Module not found: Can't resolve 'child_process' 无法解析“child_process” - Can't resolve 'child_process' 找不到模块:错误无法解析“child_process”,如何解决? - Module not found: Error can't resolve 'child_process', how to fix? 错误:无法解析'child_process'Angular-cli - Error: Can't resolve 'child_process' Angular-cli Next.js - 使用 BigQuery 客户端库时出现错误:找不到模块:无法解析“child_process” - Next.js - using BigQuery client library gives an error : Module not found: Can't resolve 'child_process' 错误:无法解析“child_process”和错误:无法解析“fs” - Error: Can't resolve 'child_process' and Error: Can't resolve 'fs' 使用Nodemailer和Webpack时无法解析dns和child_process - Can't resolve dns and child_process when using Nodemailer and Webpack 我正在尝试将 NPM package 作为插件注入到 Next.js 应用程序上,以避免出现“找不到模块:无法解析‘child_process’”错误 - I'm Trying to Inject An NPM package As A Plugin on A Next.js App to Avoid A "Module not found: Can't resolve 'child_process'" Error 节点child_process中的QPDF:找不到文件 - QPDF in node child_process: can't find file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM