Skip to content

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

Closed

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

> [email protected] 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

Activity

  1. added theissue type on Mar 8, 2025
  2. added
    plugin/webpack
    typescript
    on Mar 10, 2025
  3. erickzhao commented on Mar 10, 2025

    @erickzhao
    Member

    Hey @SebastianRzk, thanks for raising this issue. It seems like the way we import features is incompatible with the default behaviour of the --experimental-strip-types feature, which was unflagged in v23.6.0 of Node.js (https://nodejs.org/en/blog/release/v23.6.0).

    I verified this by turning the feature off after running your repro steps:

    NODE_OPTIONS="--no-experimental-strip-types" npm run package
    
  4. changed the title [-]Does not build webpack-typescript when Node-version 23.6, 23.7 and 23.8 [ERR_MODULE_NOT_FOUND][/-] [+]TypeScript Forge configuration fails to load for Node >=23.6[/+] on Mar 12, 2025
  5. removed
    plugin/webpack
    on Mar 12, 2025
  6. mohamedrhoulam commented on Mar 19, 2025

    @mohamedrhoulam

    hello @erickzhao, for the moment is there any other workaround besides running
    NODE_OPTIONS="--no-experimental-strip-types" npm run start

  7. erickzhao commented on Mar 19, 2025

    @erickzhao
    Member

    @mohamedrhoulam downgrading your Node.js version would work as well :)

  8. pedro-w commented on Mar 26, 2025

    @pedro-w

    Just to add, for Windows users, the same bug occurs and the work-around is nearly the same

    $ENV:NODE_OPTIONS="--no-experimental-strip-types"
    npm run start
    
  9. KKghub commented on May 2, 2025

    @KKghub

    This still does not work on v7.8.0 (Mar 25), I believe the fix should be available in the next version bump which has not been released yet, May I know if it will be released soon?

  10. erickzhao commented on May 2, 2025

    @erickzhao
    Member

    Oops, I went on vacation like a week after getting that PR landed. I'm back now, though, so we'll look to get a new release out soon!

  11. Crazh3 commented on May 9, 2025

    @Crazh3

    Do you have any plan to release the new version? The flowers I've been waiting for have all withered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtypescript

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions