{"record":{"id":"01cc945bd19d5339","repo":"microsoft/typescript-go","slug":"published-platform-package-npmpackagename-ver","errorCode":null,"errorMessage":"Published platform package ${npmPackageName}@${version} did not contain a lib directory.","messagePattern":"Published platform package (.+?)@(.+?) did not contain a lib directory\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":2292,"sourceCode":"        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\n\r\n    const platforms = getPlatforms();\r\n    const extensions = platforms.flatMap(({ npmDir, npmPackageName, extensions }) => extensions.map(e => ({ npmDir, npmPackageName, ...e })));\r\n    if (!extensions.length) {\r\n        console.log(\"No VSIX targets configured; skipping extension packaging.\");\r","sourceCodeStart":2274,"sourceCodeEnd":2310,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L2274-L2310","documentation":"After `npm pack` downloads and tar extracts a published platform package into a staging directory, getPublishedPlatformPackageLibDir expects a `lib/` directory at the destination (the native binary lives there). If the extracted tarball has no lib/, the package content is not what the VSIX packaging needs — wrong package layout, wrong version fetched, or a malformed publication — so it throws before returning the path.","triggerScenarios":"The tarball fetched via npm pack for `<npmPackageName>@<version>` extracts without a top-level lib/ directory — e.g. the published platform package of that version used a different layout, the version string resolved to a non-platform package, or the tarball was damaged/replaced.","commonSituations":"Pointing the alias at a version whose packages weren't built by this pipeline; a republished/overwritten tarball; a proxy serving a cached substitute; partial extraction interrupted previously leaving a bad cached dir.","solutions":["Inspect the tarball: `tar -tzf <tarballs>/<file>.tgz | head` and confirm `package/lib/` is present","Verify the version being fetched actually matches the intended published platform package (alias optionalDependencies vs lock)","Clear the staging dir (`built/published-packages` area and its tarballs) and retry so a fresh, complete extraction happens; if the published package is genuinely malformed, release a fixed platform package"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Inspect the tarball layout before extracting\nimport { execSync } from \"node:child_process\";\nconst listing = execSync(`tar -tzf ${tgzPath}`).toString();\nif (!/^package\\/lib\\//m.test(listing)) {\n  throw new Error(`${tgzPath} has no package/lib/ — wrong or malformed platform package`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify tarball contents (tar -tzf) when pulling in a new platform-package version","Clear the staging/tarballs cache between release runs so stale extractions can't linger"],"tags":["npm","packaging","tarball","vsix"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}