{"record":{"id":"33a1a78d530b37e2","repo":"yarnpkg/yarn","slug":"msg-this-token-line-this-token-col-in-t","errorCode":null,"errorMessage":"${msg} ${this.token.line}:${this.token.col} in ${this.fileLoc}","messagePattern":"\\$\\{msg\\} \\$\\{this\\.token\\.line\\}:\\$\\{this\\.token\\.col\\} in \\$\\{this\\.fileLoc\\}","errorType":"validation","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/lockfile/parse.js","lineNumber":215,"sourceCode":"  }\n\n  next(): Token {\n    const item = this.tokens.next();\n    invariant(item, 'expected a token');\n\n    const {done, value} = item;\n    if (done || !value) {\n      throw new Error('No more tokens');\n    } else if (value.type === TOKEN_TYPES.comment) {\n      this.onComment(value);\n      return this.next();\n    } else {\n      return (this.token = value);\n    }\n  }\n\n  unexpected(msg: string = 'Unexpected token') {\n    throw new SyntaxError(`${msg} ${this.token.line}:${this.token.col} in ${this.fileLoc}`);\n  }\n\n  expect(tokType: string) {\n    if (this.token.type === tokType) {\n      this.next();\n    } else {\n      this.unexpected();\n    }\n  }\n\n  eat(tokType: string): boolean {\n    if (this.token.type === tokType) {\n      this.next();\n      return true;\n    } else {\n      return false;\n    }\n  }","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/lockfile/parse.js#L197-L233","documentation":"Thrown as a `SyntaxError` by the parser's `unexpected()` method when the token stream does not match the expected grammar production. The message includes the human-readable context (`msg`), the line and column (`this.token.line:col`), and the file location (`fileLoc`). This is the generic lockfile syntax error for structurally invalid yarn.lock content beyond simple indent issues.","triggerScenarios":"The lockfile parser's `expect()`/`eat()` calls fail: e.g. a key without a colon, a value where a key is expected, a stray character. Triggered by `run()` when tokenization succeeds but grammar matching fails.","commonSituations":"Corrupted yarn.lock from a partial write or crash. Manual editing that broke structure. A merge conflict resolved by keeping both sides' text. Disk corruption.","solutions":["Open yarn.lock at the reported line:col and fix the structural error.","Regenerate the lockfile: `rm yarn.lock && yarn install`.","If in a merge, re-resolve the conflict and run `yarn install` to rewrite the lockfile.","Restore from version control: `git checkout -- yarn.lock` then `yarn install`."],"exampleFix":"# before (yarn.lock — missing colon / broken structure at reported line)\nreact@^16.0.0\n  version \"16.8.0\"\n# after\nreact@^16.0.0:\n  version \"16.8.0\"","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nfunction quickLockfileSanity(filePath) {\n  const text = fs.readFileSync(filePath, 'utf8');\n  for (const line of text.split('\\n')) {\n    // keys must end with ':' or be indented values\n    if (line.length && !line.startsWith(' ') && !line.startsWith('#') && !line.endsWith(':')) {\n      console.warn(`Possible malformed lockfile line: ${line}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseLockfile(fileLoc);\n} catch (err) {\n  if (err instanceof SyntaxError && err.message.includes('in')) {\n    reporter.error(`Corrupt yarn.lock at ${err.message}. Regenerate: rm yarn.lock && yarn install`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Treat yarn.lock as machine-generated; avoid manual structural edits.","After merging branches, run `yarn install` to let Yarn normalize the lockfile.","Restore yarn.lock from git rather than hand-repairing after corruption."],"tags":["lockfile","parse-error","syntax"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}