{"record":{"id":"9f7dc1782e4b3321","repo":"microsoft/typescript-go","slug":"package-lock-json-does-not-contain-npmpackagenam","errorCode":null,"errorMessage":"package-lock.json does not contain ${npmPackageName}; run npm install.","messagePattern":"package-lock\\.json does not contain (.+?); run npm install\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":2274,"sourceCode":"    const dest = path.join(builtPublishedPlatformPackages, \"node_modules\", ...npmPackageName.split(\"/\"));\r\n    const lib = path.join(dest, \"lib\");\r\n    if (fs.existsSync(lib)) {\r\n        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","sourceCodeStart":2256,"sourceCodeEnd":2292,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L2256-L2292","documentation":"Before fetching a platform tarball via `npm pack`, getPublishedPlatformPackageLibDir requires a matching `node_modules/<npmPackageName>` entry in the repo's package-lock.json (getPackageLock memoizes it). The lock entry supplies the resolved tarball URL and integrity metadata; without it the build cannot verify or reproducibly fetch the package, so it throws with the npm install hint.","triggerScenarios":"The alias's optionalDependencies declares the platform package, but the root package-lock.json has no `packages[\"node_modules/<name>\"]` entry — e.g. the lockfile was generated before that platform existed or was pruned by an install with the platform omitted (OS-specific optional deps not installed).","commonSituations":"Pulling a branch that added a platform without its lockfile update; running npm install with flags that skipped optional dependencies; hand-managed or partially regenerated lockfiles.","solutions":["Re-run `npm install` at the repo root so package-lock.json gains the `node_modules/<npmPackageName>` entry, then retry","Verify the entry exists afterwards: `node -p \"require('./package-lock.json').packages['node_modules/<name>']\"`","Commit the updated lockfile so other machines don't hit the same gap"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const lock = require(\"./package-lock.json\");\nconst entry = lock.packages[`node_modules/${npmPackageName}`];\nif (!entry) {\n  throw new Error(`package-lock.json missing ${npmPackageName} — run npm install and commit the lock`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate and commit package-lock.json whenever the platforms table or alias version changes","Never strip optional dependencies during install (avoid --no-optional in CI)"],"tags":["npm","package-lock","dependencies","build"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}