{"record":{"id":"0fe6e99db8f71c1d","repo":"microsoft/typescript-go","slug":"npm-pack-npmpackagename-version-did-not-retu","errorCode":null,"errorMessage":"npm pack ${npmPackageName}@${version} did not return a filename.","messagePattern":"npm pack (.+?)@(.+?) did not return a filename\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":2287,"sourceCode":"        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\n}\r\n\r\nasync function runPackVsixExtensions() {\r\n    await rimraf(builtVsix);\r\n    await fs.promises.mkdir(builtVsix, { recursive: true });\r\n    if (usePublishedPlatformPackagesForVsix) {\r\n        checkPublishedPlatformPackagesForVsix();\r\n        publishedPlatformPackageLibDirs.clear();\r\n        await rimraf(builtPublishedPlatformPackages);\r\n    }\r","sourceCodeStart":2269,"sourceCodeEnd":2305,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L2269-L2305","documentation":"getPublishedPlatformPackageLibDir fetches a platform tarball with `npm pack --json <name>@<version>` and reads `filename` from the first JSON entry to know which .tgz to extract. If npm's JSON output parses but the first entry has no usable `filename` string (unexpected npm output shape, warnings-first JSON, or a wrapper polluting stdout), the task cannot proceed and throws.","triggerScenarios":"The `npm pack --json` invocation under built/published platform packages' tarballs directory returns JSON whose first element lacks `filename` — caused by unusual npm versions, a registry proxy emitting extra output to stdout, or npm config that changes pack output.","commonSituations":"CI image with a very old/new npm whose `pack --json` shape differs; a .npmrc `prefix`/script wrapper writing to stdout; an authenticated proxy returning error JSON instead of pack metadata.","solutions":["Reproduce manually: run `npm pack --json <npmPackageName>@<version>` in the tarballs dir and inspect the exact stdout to see what npm emitted","Align the npm version with the one the release pipeline expects (Node LTS bundled npm)","Remove any wrapper/config that writes to stdout during pack, and ensure registry auth is configured so pack succeeds"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Smoke-test the toolchain shape once before the pipeline\nconst { stdout } = await $pipe`npm pack --json --dry-run <npmPackageName>@<version>`;\nconst [first] = JSON.parse(stdout);\nif (!first || typeof first.filename !== \"string\") {\n  throw new Error(\"npm pack --json output shape unexpected; pin a compatible npm version\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const [packed] = JSON.parse(stdout);\n  if (!packed?.filename) throw new Error(`npm pack did not return a filename`);\n  // proceed with extraction\n} catch (e) {\n  if (/did not return a filename/.test(String(e?.message))) {\n    // log raw stdout for diagnosis, pin npm version, fail the run — do not silently retry\n    throw new Error(`npm pack output unusable: ${stdout.slice(0, 500)}`);\n  }\n  throw e;\n}","preventionTips":["Pin the Node/npm version in CI to the one the release pipeline is built for","Keep npm configuration minimal during pack; nothing else may write to stdout"],"tags":["npm","network","registry","packaging"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}