I've experienced an issue using NPM v7 with a fresh Electron Forge project (TypeScript + WebPack variant). The project is created successfully, but on launch I receive the below error apparently originating from html-webpack-plugin.
I can confirm the error does not occur when I use Yarn, or when I revert to NPM v6 (I tried 6.14.10). What is happening?
The application should load without any error
Application fails to load due to error below.
npx create-electron-app my-new-app --template=typescript-webpackError log
> [email protected] start
> electron-forge start
✔ Checking your system
✔ Locating Application
✔ Preparing native dependencies
✔ Compiling Main Process Code
✔ Launch Dev Servers
✔ Compiling Preload Scripts
An unhandled rejection has occurred inside Forge:
TypeError: Cannot read property 'createSnapshot' of undefined
at /Users/abc/Desktop/my-new-app/node_modules/html-webpack-plugin/lib/webpack5/file-watcher-api.js:13:36
at new Promise (<anonymous>)
at Object.createSnapshot (/Users/abc/Desktop/my-new-app/node_modules/html-webpack-plugin/lib/webpack5/file-watcher-api.js:12:10)
at /Users/abc/Desktop/my-new-app/node_modules/html-webpack-plugin/lib/cached-child-compiler.js:219:35
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Electron Forge was terminated. Location:
{}
Same issue when using webpack template. M1 MBA macOS 11.2
Duplicate of #1998
Switch to NPM 6 (node 14.15.5) for project generation with create-electron-app, then switch back. Related to webpack 4 dependency in webpack plugin.
Not sure if it was due to a node, npm, or electron update but this is now working for me.
node: 15.9.0
npm: 7.5.4
electron: 12.0.0
npm install --legacy-peer-deps was how I got around this for the time being
Both downgrading to NPM 6 npm i -g npm@6, or using npm install --legacy-peer-deps work, but make sure you rm -rf node_modules folder before. I also deleted package-lock just in case.
Beta 56 uses Webpack 5.