Open
Description
Pre-flight checklist
- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project uses.
- I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
7.6.0
Electron version
v34.0.0
Operating system
Windows 10 (22H2)
Last known working Electron Forge version
Unknown
Expected behavior
After creating a new app using the default template, running npm start
should start the app, with no errors thrown
Actual behavior
The application throws the following exception in a dialog and the console:
Cannot use import statement outside a module
Steps to reproduce
- Create a new application using
npx create-electron-app@latest my-app
- Navigate to the new app's folder
- Run
npm start
Additional information
Node version: v12.13.0 LTS
Screenshot of the error dialog:
Console output when the error is thrown:
(node:13940) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `electron --trace-warnings ...` to show where the warning was created)
App threw an error during load
C:\Users\pauli\Desktop\my-app\src\index.js:1
import { app, BrowserWindow } from 'electron';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1385:20)
at Module._compile (node:internal/modules/cjs/loader:1435:41)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at cjsLoader (node:internal/modules/esm/translators:350:17)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)
at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)