{"record":{"id":"31286e50437d2ae5","repo":"microsoft/typescript-go","slug":"package-lock-json-has-npmpackagename-lockentr","errorCode":null,"errorMessage":"package-lock.json has ${npmPackageName}@${lockEntry.version}, but ${publishedTypeScriptAliasPackageName} depends on ${version}.","messagePattern":"package-lock\\.json has (.+?)@(.+?), but (.+?) depends on (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":2277,"sourceCode":"        return lib;\r\n    }\r\n\r\n    await fs.promises.mkdir(dest, { recursive: true });\r\n\r\n    const tarballDestination = path.join(builtPublishedPlatformPackages, \"tarballs\");\r\n    await fs.promises.mkdir(tarballDestination, { recursive: true });\r\n\r\n    const version = getPublishedTypeScriptPackageJson().optionalDependencies[npmPackageName];\r\n    if (!version || typeof version !== \"string\") {\r\n        throw new Error(`${publishedTypeScriptAliasPackageName} does not depend on ${npmPackageName}.`);\r\n    }\r\n\r\n    const lockEntry = getPackageLock().packages[`node_modules/${npmPackageName}`];\r\n    if (!lockEntry) {\r\n        throw new Error(`package-lock.json does not contain ${npmPackageName}; run npm install.`);\r\n    }\r\n    if (lockEntry.version !== version) {\r\n        throw new Error(`package-lock.json has ${npmPackageName}@${lockEntry.version}, but ${publishedTypeScriptAliasPackageName} depends on ${version}.`);\r\n    }\r\n    if (!lockEntry.resolved || typeof lockEntry.resolved !== \"string\") {\r\n        throw new Error(`package-lock.json entry for ${npmPackageName}@${version} does not contain a tarball URL.`);\r\n    }\r\n\r\n    console.log(`Fetching ${npmPackageName}@${version} with npm.`);\r\n    const { stdout } = await $pipe({ cwd: tarballDestination, env: releasePackageEnv })`npm pack --json ${npmPackageName}@${version}`;\r\n    const [packed] = JSON.parse(stdout);\r\n    if (!packed.filename || typeof packed.filename !== \"string\") {\r\n        throw new Error(`npm pack ${npmPackageName}@${version} did not return a filename.`);\r\n    }\r\n    await tar.x({ file: path.join(tarballDestination, packed.filename), cwd: dest, strip: 1 });\r\n\r\n    if (!fs.existsSync(lib)) {\r\n        throw new Error(`Published platform package ${npmPackageName}@${version} did not contain a lib directory.`);\r\n    }\r\n\r\n    return lib;\r","sourceCodeStart":2259,"sourceCodeEnd":2295,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L2259-L2295","documentation":"getPublishedPlatformPackageLibDir requires package-lock.json's entry for the platform package to have exactly the same version string the alias's optionalDependencies declares. The lockfile is the source of the resolved tarball URL, so a lock/manifest disagreement would fetch a different build than the alias ships; the task aborts instead of mixing versions.","triggerScenarios":"The alias was updated to a new version (e.g. dev.25.0) but package-lock.json still pins the platform package at the old one (e.g. dev.24.9) — a stale lockfile after a version bump or branch switch.","commonSituations":"Version bumped in CI without regenerating the lock; switching release branches with different dev versions; partial `npm install` that updated node_modules but not the lock.","solutions":["Run `npm install` at the repo root to resync package-lock.json with the alias's optionalDependencies, then retry","Confirm both sides match: compare the alias optionalDependencies value with `require('./package-lock.json').packages['node_modules/<name>'].version`","If the lock is intentionally pinned, align the alias install to the pinned version instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const lockEntry = require(\"./package-lock.json\").packages[`node_modules/${npmPackageName}`];\nconst wanted = require(\"@typescript/bundled-typescript/package.json\").optionalDependencies[npmPackageName];\nif (lockEntry && lockEntry.version !== wanted) {\n  throw new Error(`Lock ${lockEntry.version} != alias ${wanted} — run npm install`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat lock/manifest version drift as a build input error: reinstall before every release run","Automate the lock-vs-optionalDependencies comparison in a pre-flight check"],"tags":["npm","package-lock","versioning","dependencies"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}