Skip to content

TypeScript Forge configuration fails to load for Node >=23.6 #3872

@SebastianRzk

Description

@SebastianRzk

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.

Forge version

7.6.1 aswell as 7.7.0

Electron version

34.0.0

Operating system

Arch Linux

Last known working Forge version

7.7.0 but with Node 23.5

Expected behavior

The command npm run package should work on node-versions greater than 23.5 as "good" as on version 23.5 and less.

Actual behavior

On node 23.6, 23.7 and 23.8:

pm run package

> my-app@1.0.0 package
> electron-forge package

✔ Checking your system
✖ Preparing to package application
  ›
    1. Cannot find module '/tmp/test/my-app/webpack.main.config' imported from /tmp/test/my-app/forge.config.ts
    2. Cannot find module '/tmp/test/my-app/webpack.main.config' imported from /tmp/test/my-app/forge.config.ts
◼ Running packaging hooks
◼ Packaging application
◼ Running postPackage hook

(node:7471) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Failed to load: /tmp/test/my-app/forge.config.ts
(node:7471) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///tmp/test/my-app/forge.config.ts is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /tmp/test/my-app/package.json.

An unhandled rejection has occurred inside Forge:
Error [ERR_MODULE_NOT_FOUND]: 
1. Cannot find module '/tmp/test/my-app/webpack.main.config' imported from /tmp/test/my-app/forge.config.ts
2. Cannot find module '/tmp/test/my-app/webpack.main.config' imported from /tmp/test/my-app/forge.config.ts
at finalizeResolution (node:internal/modules/esm/resolve:275:11)
    at moduleResolve (node:internal/modules/esm/resolve:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:719:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:643:25)
    at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:678:38)
    at ModuleLoader.resolveSync (node:internal/modules/esm/loader:701:52)
    at #cachedResolveSync (node:internal/modules/esm/loader:662:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:390:50)
    at new ModuleJobSync (node:internal/modules/esm/module_job:342:34)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:363:11)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1565:24)
    at Module._compile (node:internal/modules/cjs/loader:1716:5)
    at Object.loadTS [as .ts] (node:internal/modules/cjs/loader:1826:10)
    at Module.load (node:internal/modules/cjs/loader:1469:32)
    at Function._load (node:internal/modules/cjs/loader:1286:12)

Steps to reproduce

  1. Generate empty project from template: npx create-electron-app@latest my-app --template=webpack-typescript
  2. Change into the directory cd my-app
  3. Run npm run package

Additional information

When I switch with nvm to node 23.5, it works again

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtypescriptIssues relating to use of TypeScript with Forge

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions