electron-react-boilerplate / electron-react-boilerplate

A Foundation for Scalable Cross-Platform Apps

Home Page:https://electron-react-boilerplate.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't import child_process

taxuexunshang opened this issue · comments

Hello, I want to use child_process to invoke an exe file in a React + Electron Project. But some error happend when I import child_process module.
The first is Module not found: Error: Can't resolve 'child_process'
I solve it by add
"browser": { "child_process": false } to package.json ,It package successfully.
But when I click a button which use child_process invoke an external exe. It will throw a second error spawn() is not a function.
I have tried

  • change import { spawn } from 'child_process' to const { spawn } = require('child_process')

I just add a button to test child_process spawn() invoke an exe.
Please help me, thanks~