electron / electron/forge

Forge make combined with vite is creating an incomplete asar

Open
#3,738 57 comments 23 reactions 1 assignee Claimed by @erickzhao View on GitHub
bug plugin/vite
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.

### Electron Forge version

7.5.0

### Electron version

33.0.1

### Operating system

windows 11

### Last known working Electron Forge version

7.4.0

### Expected behavior

npm run make creates an asar file that includes the node_modules and the app can run on windows successfully.

### Actual behavior

node_modules aren't present and install fails with ERR_MODULE_NOT_FOUND

### Steps to reproduce

1. npm run make
2. go to the out folder and find open the nupkg/resources/app.asar file
3. run npx @electron/asar extract app.asar app
4. notice there is no node_modules

### Additional information

This is only happening on windows as I believe that is the only place that asar is used.
We are using vite instead of webpack.

![Image](https://github.com/user-attachments/assets/371fad6b-51ba-4bab-a49d-86cf4eb5f86c)

The main.js file from within the asar in the error message imports the following

```js
import "node:path";
import "node:url";
import "electron";
import "electron-window-state";
import "update-electron-app";
import "./main-DWMHPuxT.js";
import "electron-squirrel-startup";
import "fs";
import "path";
import "url";
import "stream";
import "zlib";
```

Where electron-window-state and update-electron-app and I assume electron-squirrel-startup are not available to be imported.

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.