Open steveoh opened 1 month ago
I'm not sure about 7.5.0 but in earlier versions it was needed to move electron-window-state
and any other dependency that isn't getting bundled correctly to devDependencies in package.json, This is a known mismatch between vite and webpack in forge.
This works as expected downgrading to 7.4.0. I'll give this a try but no bundles are getting added to the app.asar file at 7.5.0.
Well now I'm getting a require is not defined error after making the project. :/
@steveoh I use electron-log and it works fine after downgrading.
I've had this happen to ubuntu as well, but found a way to get the trick: When you run "npm run make" for the first time, open the @electron-forge/plugin-vite configuration, get the .vite/ folder, and delete the out/ folder; Then turn off the @electron-forge/plugin-vite config and run "npm run make" again to get a complete installer
Ran into a similar issue with other packages. Found a work-around and modified it to work for me. Seems @electron/packager
related.
// forge.config.js
const { spawn } = require('node:child_process');
module.exports = {
hooks: {
packageAfterPrune: async (config, build_path) => {
const vite_config = await import('./vite.preload.config.mjs');
const external = vite_config?.default?.build?.rollupOptions?.external || [];
const commands = [
'install',
'--no-package-lock',
'--no-save',
...external,
];
return new Promise((resolve, reject) => {
npm = spawn('npm', commands, {
cwd: build_path,
stdio: 'inherit',
shell: true,
});
npm.on('close', (code) => {
if (0 === code) {
resolve();
return;
}
reject(`Process exited with code: ${code}`);
});
npm.on('error', reject);
});
},
},
// ...
};
same issue here, happens when trying to load a json file
const filePath = path.join(__dirname, "schedule.json");
const data = fs.readFileSync(filePath , "utf-8");
temp workaround is to disable asar by modifying the following properties in forge.config.ts
const config: ForgeConfig = {
packagerConfig: {
asar: false,
},
plugins: [
new FusesPlugin({
[FuseV1Options.OnlyLoadAppFromAsar]: false,
}),
],
};
This error is not related to ASAR. Even if ASAR is disabled, the error is still reported. I think it is a vite plug-in problem. It works normally in 7.4.0
Pre-flight checklist
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
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.
The main.js file from within the asar in the error message imports the following
Where electron-window-state and update-electron-app and I assume electron-squirrel-startup are not available to be imported.