Can't import child_process
taxuexunshang opened this issue · comments
踏雪寻殇 commented
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'
toconst { spawn } = require('child_process')
I just add a button to test child_process spawn() invoke an exe.
Please help me, thanks~