{"record":{"id":"d3c405aeee910a34","repo":"parcel-bundler/parcel","slug":"error-parsing-path-relative-this-options-inputfs","errorCode":null,"errorMessage":"Error parsing ${path.relative(this.options.inputFS.cwd(), pkgFile)}: ${err.message}","messagePattern":"Error parsing (.+?): (.+?)","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/EntryRequest.js","lineNumber":369,"sourceCode":"  async readPackage(entry: FilePath): Promise<?{\n    ...PackageJSON,\n    filePath: FilePath,\n    map: {|data: mixed, pointers: {|[string]: Mapping|}|},\n    ...\n  }> {\n    let content, pkg;\n    let pkgFile = path.join(entry, 'package.json');\n    try {\n      content = await this.options.inputFS.readFile(pkgFile, 'utf8');\n    } catch (err) {\n      return null;\n    }\n\n    try {\n      pkg = JSON.parse(content);\n    } catch (err) {\n      // TODO: code frame?\n      throw new ThrowableDiagnostic({\n        diagnostic: {\n          message: md`Error parsing ${path.relative(\n            this.options.inputFS.cwd(),\n            pkgFile,\n          )}: ${err.message}`,\n        },\n      });\n    }\n\n    return {\n      ...pkg,\n      filePath: pkgFile,\n      map: parse(content, undefined, {tabWidth: 1}),\n    };\n  }\n}\n","sourceCodeStart":351,"sourceCodeEnd":386,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/EntryRequest.js#L351-L386","documentation":"Thrown by readPackage() when JSON.parse(content) fails on a package.json file that was successfully read from disk. The error includes the relative path to the package.json and the underlying JSON parse error message.","triggerScenarios":"Called from resolveEntry() when the entry is a directory. readPackage() reads <entry>/package.json, and if JSON.parse(content) throws (SyntaxError), the ThrowableDiagnostic is raised with err.message (e.g., 'Unexpected token').","commonSituations":"Hand-editing package.json and leaving a trailing comma, unquoted key, or missing brace; JSON5-only syntax (comments, unquoted keys) in a file parsed as strict JSON; copy-paste introducing smart quotes or invisible characters; truncated file from a git merge conflict.","solutions":["Validate the package.json with a JSON linter: npx jsonlint package.json or use your editor's JSON validation.","Look for the specific parse error in the message (line/column) and fix that exact location.","Remove trailing commas, ensure all keys are double-quoted, and remove comments.","If package.json was corrupted by a merge conflict, resolve the conflict markers first.","Use a JSON formatter/prettier to auto-fix structural issues: npx prettier --write package.json."],"exampleFix":"// before — package.json (invalid)\n{\n  \"name\": \"app\",\n  \"source\": \"index.html\",\n}\n\n// after\n{\n  \"name\": \"app\",\n  \"source\": \"index.html\"\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction validatePackageJson(pkgPath) {\n  const content = fs.readFileSync(pkgPath, 'utf8');\n  try {\n    JSON.parse(content);\n  } catch (e) {\n    throw new Error(`Invalid JSON in ${pkgPath}: ${e.message}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an editor with JSON validation/syntax checking.","Run npx jsonlint package.json in CI or as a precommit hook.","Avoid hand-editing large package.json — use npm/pkg commands which preserve validity."],"tags":["package-json","json-parse","config","syntax-error"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}