{"record":{"id":"ae7b9c12687bc37a","repo":"davila7/claude-code-templates","slug":"could-not-parse-package-json","errorCode":null,"errorMessage":"Could not parse package.json","messagePattern":"Could not parse package\\.json","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli-tool/src/utils.js","lineNumber":31,"sourceCode":"      detectedLanguages.push('javascript-typescript');\n      \n      // Detect frameworks\n      const dependencies = { ...packageJson.dependencies, ...packageJson.devDependencies };\n      \n      if (dependencies.react || dependencies['@types/react']) {\n        detectedFrameworks.push('react');\n      }\n      if (dependencies.vue || dependencies['@vue/cli']) {\n        detectedFrameworks.push('vue');\n      }\n      if (dependencies['@angular/core']) {\n        detectedFrameworks.push('angular');\n      }\n      if (dependencies.express || dependencies.fastify || dependencies.koa) {\n        detectedFrameworks.push('node');\n      }\n    } catch (error) {\n      console.warn('Could not parse package.json');\n    }\n  }\n  \n  // Check for Python files\n  const pythonFiles = await findFilesByExtension(targetDir, ['.py']);\n  if (pythonFiles.length > 0) {\n    detectedLanguages.push('python');\n    \n    // Check for Python frameworks\n    const requirementsPath = path.join(targetDir, 'requirements.txt');\n    const pipfilePath = path.join(targetDir, 'Pipfile');\n    const pyprojectPath = path.join(targetDir, 'pyproject.toml');\n    \n    if (await fs.pathExists(requirementsPath)) {\n      const requirements = await fs.readFile(requirementsPath, 'utf-8');\n      if (requirements.includes('django')) detectedFrameworks.push('django');\n      if (requirements.includes('flask')) detectedFrameworks.push('flask');\n      if (requirements.includes('fastapi')) detectedFrameworks.push('fastapi');","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/utils.js#L13-L49","documentation":"detectProject warns when it cannot read or JSON.parse the project's package.json while detecting Node frameworks. Detection simply skips Node framework detection and continues with other checks (Python, Ruby, etc.).","triggerScenarios":"package.json exists but contains invalid JSON (trailing comma, comment, truncated file), or readFile throws due to permissions; the catch swallows the specific error message.","commonSituations":"Hand-edited package.json with a syntax error, merge-conflict markers left in the file, or a package.json with JSONC-style comments (some tools tolerate them, JSON.parse does not).","solutions":["Validate the file: npx jsonlint package.json or node -e \"require('./package.json')\"","Fix the JSON syntax error (commas, quotes, conflict markers)","Re-run the CLI so framework detection includes Node"],"exampleFix":"// before\n{\n  \"name\": \"app\",\n  \"scripts\": { \"dev\": \"vite\" } // trailing stuff\n}\n// after\n{\n  \"name\": \"app\",\n  \"scripts\": { \"dev\": \"vite\" }\n}","handlingStrategy":"validation","validationCode":"JSON.parse(require('fs').readFileSync('package.json', 'utf8')); // run in a precheck script or CI lint step","typeGuard":"function isValidPkg(o) { return o != null && typeof o === 'object'; }","tryCatchPattern":null,"preventionTips":["Lint package.json in CI (npm pkg lint or jsonlint)","Never hand-edit package.json without validating afterwards"],"tags":["json","package-json","project-detection"],"backgroundTag":"invalid-json-config","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}