Electron-forge: [6.0.0-beta.54] NPM v7 causing error on launch

Created on 21 Dec 2020  Â·  6Comments  Â·  Source: electron-userland/electron-forge

Preflight Checklist

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

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?

  • Electron Forge Version:

    • 6.0.0-beta.54

  • Electron Version:

    • 11.1.0

  • Operating System:

    • macOS 10.15.7 (19H15)

  • Last Known Working Electron Forge version::

    • N/A

Expected Behavior

The application should load without any error

Actual Behavior

Application fails to load due to error below.

To Reproduce

  • Install NPM 7.3.0
  • npx create-electron-app my-new-app --template=typescript-webpack
  • Run the application
  • Experience the error
  • If the error does not happen, remove the node_modules and package-lock.json and reinstall and run (error should occur)

Additional Information

Error 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:
{}
Bug

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings