{"record":{"id":"c8d888b883f130d0","repo":"microsoft/typescript-go","slug":"publishedtypescriptaliaspackagename-package-jso","errorCode":null,"errorMessage":"${publishedTypeScriptAliasPackageName} package.json did not contain a version.","messagePattern":"(.+?) package\\.json did not contain a version\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":2210,"sourceCode":"});\r\n\r\n/** @type {Map<string, Promise<string>>} */\r\nconst publishedPlatformPackageLibDirs = new Map();\r\n\r\nconst getPublishedTypeScriptPackageJson = memoize(() => {\r\n    const candidates = [\r\n        path.join(extensionDir, \"node_modules\", publishedTypeScriptAliasPackageName, \"package.json\"),\r\n        path.join(__dirname, \"node_modules\", publishedTypeScriptAliasPackageName, \"package.json\"),\r\n    ];\r\n\r\n    for (const candidate of candidates) {\r\n        if (fs.existsSync(candidate)) {\r\n            const packageJson = JSON.parse(fs.readFileSync(candidate, \"utf8\"));\r\n            if (packageJson.name !== \"typescript\") {\r\n                throw new Error(`${publishedTypeScriptAliasPackageName} should alias the typescript package, but found ${packageJson.name}.`);\r\n            }\r\n            if (!packageJson.version || typeof packageJson.version !== \"string\") {\r\n                throw new Error(`${publishedTypeScriptAliasPackageName} package.json did not contain a version.`);\r\n            }\r\n            if (!packageJson.optionalDependencies || typeof packageJson.optionalDependencies !== \"object\") {\r\n                throw new Error(`${publishedTypeScriptAliasPackageName} package.json did not contain platform optionalDependencies.`);\r\n            }\r\n            return packageJson;\r\n        }\r\n    }\r\n\r\n    throw new Error(`Could not find ${publishedTypeScriptAliasPackageName}; run npm install first.`);\r\n});\r\n\r\nfunction getPublishedTypeScriptVersion() {\r\n    const version = getPublishedTypeScriptPackageJson().version;\r\n    const expectedVersion = getVersion();\r\n    if (usePublishedPlatformPackagesForVsix && version !== expectedVersion) {\r\n        throw new Error(`usePublishedPlatformPackagesForVsix requires ${publishedTypeScriptAliasPackageName}'s installed version (${version}) to match release version ${expectedVersion}.`);\r\n    }\r\n    return version;\r","sourceCodeStart":2192,"sourceCodeEnd":2228,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L2192-L2228","documentation":"Second validation inside getPublishedTypeScriptPackageJson: after confirming the resolved `@typescript/bundled-typescript` package.json has `name: \"typescript\"`, it requires a string `version` field because the whole published-platform flow (VSIX packaging against published platform packages) keys every download off that version. A missing or non-string version makes the alias unusable, so it throws.","triggerScenarios":"The alias package.json parses as JSON but has no `version` field (or a non-string one) — e.g. a truncated/partially written file from an interrupted install, a hand-edited package.json, or a malformed tarball from a registry mirror.","commonSituations":"Interrupted npm install leaving a truncated package.json; someone stripped fields while debugging node_modules; a private registry proxy serving a rewritten package.json.","solutions":["Open the candidate `@typescript/bundled-typescript/package.json` and check whether `version` exists and is a string","Remove the corrupted directory and re-run `npm install` at the repo root to restore a clean copy","If it recurs, verify registry configuration (.npmrc) and disk state (no ENOSPC during install)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const pj = JSON.parse(fs.readFileSync(aliasPath, \"utf8\"));\nif (typeof pj.version !== \"string\" || pj.version.length === 0) {\n  throw new Error(`${aliasPath} is malformed (no version) — reinstall`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat a package.json missing `version` as a corrupted install: delete and reinstall rather than patch it","Run `npm ci` in CI so installs are atomic and lockfile-exact"],"tags":["npm","dependencies","packaging","corruption"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}