You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Electron Forge version
7.3.1
Electron version
v29.1.6
Operating system
Windows11
Last known working Electron Forge version
No response
Expected behavior
After packaging, the application runs normally
Actual behavior
It can be used normally with electron-forge start before it is packaged.
Startup error after packaging:
uncaught Exception TypeError [ERR_INVALID_ARG_TYPE]: The 'path' argument must be of type string. Received undefined
import type { ConfigEnv, UserConfig } from "vite";
import { defineConfig, mergeConfig } from "vite";
import { getBuildConfig, external, pluginHotRestart } from "./vite.base.config";
import path from "path";
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<"build">;
const { forgeConfigSelf } = forgeEnv;
const config: UserConfig = {
build: {
rollupOptions: {
external,
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
input: forgeConfigSelf.entry!,
output: {
format: "cjs",
// It should not be split chunks.
inlineDynamicImports: true,
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
assetFileNames: "[name].[ext]",
},
},
},
plugins: [pluginHotRestart("reload")],
};
return mergeConfig(getBuildConfig(forgeEnv), config);
});
vite.renderer.config.ts
import path from "path";
import react from "@vitejs/plugin-react";
import type { ConfigEnv, UserConfig } from "vite";
import { defineConfig } from "vite";
import { pluginExposeRenderer } from "./vite.base.config";
// https://vitejs.dev/config
export default defineConfig((env) => {
// @ts-ignore
const forgeEnv = env as ConfigEnv<"renderer">;
const { root, mode, forgeConfigSelf } = forgeEnv;
const name = forgeConfigSelf.name ?? "";
return {
root,
mode,
base: "./",
build: {
outDir: `.vite/renderer/${name}`,
},
plugins: [pluginExposeRenderer(name), react()],
resolve: {
preserveSymlinks: true,
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
clearScreen: false,
} as UserConfig;
});
forge.config.ts
import type { ForgeConfig } from "@electron-forge/shared-types";
import { MakerZIP } from "@electron-forge/maker-zip";
import { MakerRpm } from "@electron-forge/maker-rpm";
import { VitePlugin } from "@electron-forge/plugin-vite";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
import { FuseV1Options, FuseVersion } from "@electron/fuses";
import path from "path";
import configs from "./package.json";
const iconPath = path.resolve(__dirname, "src/assets/favicon");
const iconPathWithSuffix = iconPath + ".ico";
const appVersion = configs.version;
const config: ForgeConfig = {
packagerConfig: {
asar: true,
icon: iconPath,
appVersion: appVersion,
extraResource: [path.resolve(__dirname, "data")],
},
rebuildConfig: {},
makers: [
{
name: "@electron-forge/maker-squirrel",
config: {
iconUrl: iconPathWithSuffix,
setupIcon: iconPathWithSuffix,
},
},
{
name: "@electron-forge/maker-deb",
config: {
options: {
// Path to a single image that will act as icon for the application
icon: iconPathWithSuffix,
},
},
},
new MakerZIP({}, ["darwin"]),
new MakerRpm({}),
],
plugins: [
new VitePlugin({
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
// If you are familiar with Vite configuration, it will look really familiar.
build: [
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: "src/main.ts",
config: "vite.main.config.ts",
},
{
entry: "src/preload.ts",
config: "vite.preload.config.ts",
},
],
renderer: [
{
name: "main_window",
config: "vite.renderer.config.ts",
},
],
}),
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
export default config;
forge.env.d.ts
export {}; // Make this a module
declare global {
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Vite
// plugin that tells the Electron app where to look for the Vite-bundled app code (depending on
// whether you're running in development or production).
const MAIN_WINDOW_VITE_DEV_SERVER_URL: string;
const MAIN_WINDOW_VITE_NAME: string;
namespace NodeJS {
interface Process {
// Used for hot reload after preload scripts.
viteDevServers: Record<string, import("vite").ViteDevServer>;
}
}
type VitePluginConfig = ConstructorParameters<
typeof import("@electron-forge/plugin-vite").VitePlugin
>[0];
interface VitePluginRuntimeKeys {
VITE_DEV_SERVER_URL: `${string}_VITE_DEV_SERVER_URL`;
VITE_NAME: `${string}_VITE_NAME`;
}
}
declare module "vite" {
interface ConfigEnv<K extends keyof VitePluginConfig = keyof VitePluginConfig> {
root: string;
forgeConfig: VitePluginConfig;
forgeConfigSelf: VitePluginConfig[K][number];
}
}
The text was updated successfully, but these errors were encountered:
Thank you for taking the time to reply
I spent the afternoon re-combing through my code and found out that it was a problem with the typeorm entity.
But I still have a problem, when the error appears after clicking confirm, the process will run in the background without ending.
How do I end the background process in code.
Pre-flight checklist
Electron Forge version
7.3.1
Electron version
v29.1.6
Operating system
Windows11
Last known working Electron Forge version
No response
Expected behavior
After packaging, the application runs normally
Actual behavior
It can be used normally with
electron-forge start
before it is packaged.Startup error after packaging:
uncaught Exception TypeError [ERR_INVALID_ARG_TYPE]: The 'path' argument must be of type string. Received undefined
Steps to reproduce
package.json
tsconfig.json
Additional information
vite.ase.config.ts
vite.main.config.ts
vite.preload.config.ts
vite.renderer.config.ts
forge.config.ts
forge.env.d.ts
The text was updated successfully, but these errors were encountered: