{"record":{"id":"1a781aef6c6b484c","repo":"jeecgboot/JeecgBoot","slug":"appid-or-productname-not-found","errorCode":null,"errorMessage":"appId or productName not found","messagePattern":"appId or productName not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"jeecgboot-vue3/electron/script/buildBefore.ts","lineNumber":21,"sourceCode":"\nconst root = path.join(__dirname, '../../');\nconst electronDistRoot = path.join(root, 'dist/electron');\n\nlet yamlName = 'electron-builder.yaml';\nconst sourcePath = fs.readFileSync(path.join(root, yamlName), 'utf-8');\n\ntry {\n  // 通过正则表达式匹配 appId 和 productName\n  const appIdMatch = sourcePath.match(/appId:\\s*['\"]([^'\"]+)['\"]/);\n  const productNameMatch = sourcePath.match(/productName:\\s*['\"]([^'\"]+)['\"]/);\n  if (appIdMatch && productNameMatch) {\n    const fileContent = `${appIdMatch[0]}\\n${productNameMatch[0]}`;\n    yamlName = 'env.yaml';\n    const targetPath = path.join(electronDistRoot, yamlName);\n    fs.writeFileSync(targetPath, fileContent, 'utf-8');\n    console.log(`✨ write dist ${yamlName} successfully.`);\n  } else {\n    throw new Error('appId or productName not found');\n  }\n} catch (e) {\n  console.error(e);\n  console.error(`请检查 ${yamlName} 是否存在，或者内容是否正确`);\n  process.exit(1);\n}\n","sourceCodeStart":3,"sourceCodeEnd":28,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecgboot-vue3/electron/script/buildBefore.ts#L3-L28","documentation":"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*['\"]([^'\"]+)['\"].","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (electron-builder.yaml)\nappId: com.example.app\nproductName: MyApp\n\n// after (values must be quoted to satisfy the regex)\nappId: \"com.example.app\"\nproductName: \"MyApp\"","handlingStrategy":"validation","validationCode":"// Before running the electron build, assert the yaml is well-formed\nimport fs from 'fs';\nimport path from 'path';\nconst yaml = fs.readFileSync(path.join(root, 'electron-builder.yaml'), 'utf-8');\nconst hasAppId = /appId:\\s*['\"][^'\"]+['\"]/.test(yaml);\nconst hasProductName = /productName:\\s*['\"][^'\"]+['\"]/.test(yaml);\nif (!hasAppId || !hasProductName) {\n  console.error('electron-builder.yaml must define quoted appId and productName');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["electron","build","config","yaml","ci"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}