I have been dealing with this issue for a while, trying different stackoverflow solutions, AI advice, multiple re-writes, and I am still very puzzles by it.
I have a react electron app, which works fine, but if I try to import the ‘execa’ module:
import { execa } from 'execa';
I always get these error messages:
[0] Failed to compile.
[0]
[0] Module not found: Error: Can't resolve 'child_process' in '/home/martin/Documents/projects/electron-ghactions/node_modules/cross-spawn'
[0] ERROR in ./node_modules/cross-spawn/index.js 3:11-35
[0] Module not found: Error: Can't resolve 'child_process' in '/home/martin/Documents/projects/electron-ghactions/node_modules/cross-spawn'
[0]
[0] ERROR in ./node_modules/cross-spawn/lib/parse.js 3:13-28
[0] Module not found: Error: Can't resolve 'path' in '/home/martin/Documents/projects/electron-ghactions/node_modules/cross-spawn/lib'
[0]
[0] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
[0] This is no longer the case. Verify if you need this module and configure a polyfill for it.
[0]
[0] If you want to include a polyfill, you need to:
[0] - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
[0] - install 'path-browserify'
[0] If you don't want to include a polyfill, you can use an empty module like this:
[0] resolve.fallback: { "path": false }
[0]
It happens when I try to import execa at this line in my file ‘FFmpeg.js’ inside of this repo:
https://github.com/MartinBarker/electron-ghactions/blob/e76d643302cdc8601c11877eff8b43f2d5977c65/src/Ffmpeg.js#L3
The thing that confuses me, is that I have a separate repo doing a very similar thing, react and electron, which can import and use this line totally fine with no error:
const execa = window.require('execa');
https://github.com/MartinBarker/RenderTune/blob/59450b3f8445731e419c99335e7ebf7dbca6cbdf/src/FFmpeg.js#L4C1-L4C39
I’ve tried taking all the dependency versions from the working repo package.json and moving them to my non working repo, but the error still persists. Is there a config setting inside my electron-ghactions
repo package.json file causing this error? How can I allow for the importing of execa inside my react component FFmpeg.js ?