electron / electron/forge

Forge build fails on macos-latest with "Loading configuration [FAILED: Cannot use 'import.meta' outside a module]"

Open
#4,031 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Forge version

7.9.0

### Electron version

38.2.2

### Operating system

`macos-latest` (GitHub Actions)

### Last known working Forge version

_No response_

### Expected behavior

Build successfully

### Actual behavior

Build fails
```
> electron-forge make

❯ Checking your system
❯ Checking package manager version
✔ Found npm@10.9.3
✔ Checking your system
25h❯ Loading configuration
Failed to load: /Users/runner/work/structure/structure/client/forge.config.mts
✖ Loading configuration [FAILED: Cannot use 'import.meta' outside a module]

An unhandled rejection has occurred inside Forge:
SyntaxError: Cannot use 'import.meta' outside a module
25h
Error: Process completed with exit code 1.
```
(the `package.json` *does* have `"type": "module",`)

### Steps to reproduce

Happens only on GitHub Actions `macos-latest`
Sample repo: https://github.com/neopostmodern/structure (`client` subpackage, or run `npm run client:build:electron` from root package)

### Additional information

Seems similar to #4029, but changing the node.js version has no effect
It was a non-ESM project before, then the error showed up and I hoped switching to ESM entirely would fix it (but it didn't)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.