jeecgboot/JeecgBoot · error
appId or productName not found
Error message
appId or productName not found
What it means
This is a build-time error thrown by the Electron pre-build script (buildBefore.ts). The script reads electron-builder.yaml from the project root and regex-matches two keys: 'appId' and 'productName', both expecting a quoted value (single or double quotes). If either regex match returns null, the script throws and calls process.exit(1), aborting the entire Electron build. The regex specifically requires the colon-colon-quote pattern: /appId:\s*['"]([^'"]+)['"].
Source
Thrown at jeecgboot-vue3/electron/script/buildBefore.ts:21
const root = path.join(__dirname, '../../');
const electronDistRoot = path.join(root, 'dist/electron');
let yamlName = 'electron-builder.yaml';
const sourcePath = fs.readFileSync(path.join(root, yamlName), 'utf-8');
try {
// 通过正则表达式匹配 appId 和 productName
const appIdMatch = sourcePath.match(/appId:\s*['"]([^'"]+)['"]/);
const productNameMatch = sourcePath.match(/productName:\s*['"]([^'"]+)['"]/);
if (appIdMatch && productNameMatch) {
const fileContent = `${appIdMatch[0]}\n${productNameMatch[0]}`;
yamlName = 'env.yaml';
const targetPath = path.join(electronDistRoot, yamlName);
fs.writeFileSync(targetPath, fileContent, 'utf-8');
console.log(`✨ write dist ${yamlName} successfully.`);
} else {
throw new Error('appId or productName not found');
}
} catch (e) {
console.error(e);
console.error(`请检查 ${yamlName} 是否存在,或者内容是否正确`);
process.exit(1);
}
View on GitHub (pinned to 96fb33f5ec)
Solutions
- Verify electron-builder.yaml exists at the repo root and contains both keys with quoted values, e.g. `appId: "com.example.app"` and `productName: "MyApp"`.
- If the file is missing, restore it from git or copy from a template and fill in real values.
- Ensure values are wrapped in single or double quotes — the regex requires them.
- Run the build script standalone (`node electron/script/buildBefore.ts` or via tsx) to see the exact regex failure before running the full build.
Example fix
// before (electron-builder.yaml) appId: com.example.app productName: MyApp // after (values must be quoted to satisfy the regex) appId: "com.example.app" productName: "MyApp"
Defensive patterns
Strategy: validation
Validate before calling
// Before running the electron build, assert the yaml is well-formed
import fs from 'fs';
import path from 'path';
const yaml = fs.readFileSync(path.join(root, 'electron-builder.yaml'), 'utf-8');
const hasAppId = /appId:\s*['"][^'"]+['"]/.test(yaml);
const hasProductName = /productName:\s*['"][^'"]+['"]/.test(yaml);
if (!hasAppId || !hasProductName) {
console.error('electron-builder.yaml must define quoted appId and productName');
process.exit(1);
} Prevention
- Commit electron-builder.yaml with quoted appId/productName values.
- Add a CI step that runs buildBefore.ts in isolation before the full build.
- Document the quote requirement in a comment at the top of the yaml.
When it happens
Trigger: Running `pnpm build` (or the electron build target) when electron-builder.yaml is missing, is empty, or does not contain both `appId: "..."` and `productName: "..."` lines with quoted values. Also triggered if the keys use YAML flow syntax without quotes (e.g. `appId: com.app` unquoted), or if indentation/comment formatting breaks the single-line regex match.
Common situations: Renaming or relocating electron-builder.yaml; switching between electron and non-electron build configs and forgetting to populate the yaml; YAML values written unquoted; trailing inline comments on the same line (`appId: "x" # comment`) which still match but can confuse downstream; fresh clone where the yaml is gitignored.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/1a781aef6c6b484c.
Report an issue: GitHub.