{"record":{"id":"bea53cc91eb03124","repo":"microsoft/typescript-go","slug":"unable-to-resolve-platformpackagename-either-y","errorCode":null,"errorMessage":"Unable to resolve ${platformPackageName}. Either your platform is unsupported, or you are missing the package on disk.","messagePattern":"Unable to resolve (.+?)\\. Either your platform is unsupported, or you are missing the package on disk\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"_packages/native-preview/lib/getExePath.js","lineNumber":53,"sourceCode":"    else {\r\n        // We're actually running from an installed package.\r\n        const platformPackageName = \"@typescript/\" + expectedPackage;\r\n        try {\r\n            if (typeof import.meta.resolve === \"undefined\") {\r\n                // v16.20.1\r\n                const require = module.createRequire(import.meta.url);\r\n                const packageJson = require.resolve(platformPackageName + \"/package.json\");\r\n                exeDir = path.join(path.dirname(packageJson), \"lib\");\r\n            }\r\n            else {\r\n                // v20.6.0, v18.19.0\r\n                const packageJson = import.meta.resolve(platformPackageName + \"/package.json\");\r\n                const packageJsonPath = fileURLToPath(packageJson);\r\n                exeDir = path.join(path.dirname(packageJsonPath), \"lib\");\r\n            }\r\n        }\r\n        catch (e) {\r\n            throw new Error(\"Unable to resolve \" + platformPackageName + \". Either your platform is unsupported, or you are missing the package on disk.\");\r\n        }\r\n    }\r\n\r\n    let exe = path.join(exeDir, binName);\r\n    if (process.platform === \"win32\") {\r\n        exe += \".exe\";\r\n        if (exe.length >= 248) {\r\n            exe = \"\\\\\\\\?\\\\\" + exe;\r\n        }\r\n    }\r\n\r\n    if (!fs.existsSync(exe)) {\r\n        throw new Error(\"Executable not found: \" + exe);\r\n    }\r\n\r\n    return exe;\r\n}\r\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_packages/native-preview/lib/getExePath.js#L35-L71","documentation":"Thrown by getExePath() when the package runs from an installed location (not repo source, not built npm output) and neither require.resolve nor import.meta.resolve can resolve @typescript/<name>-<platform>-<arch>/package.json. The platform binary ships as an optional dependency with os/cpu constraints; the throw means that dependency is absent on disk or does not exist for your platform.","triggerScenarios":"npm/pnpm/yarn installed with optional dependencies skipped (--no-optional / --omit=optional / Node modules config) or the classic npm optional-deps bug; installing on an unsupported platform or architecture (no prebuilt package published); corrupted node_modules where the platform package directory is missing; Node older than 18.19/20.6 combined with a broken require context.","commonSituations":"CI images that strip optional deps to slim layers; Docker builds with --omit=optional; corporate proxies mangling installs; unusual arches (e.g., armv7, freebsd, 32-bit) with no tsgo prebuilt; pnpm hoisting layouts hiding the optional package.","solutions":["Reinstall with optional dependencies included: npm install --include=optional (or drop --omit=optional) after removing node_modules","Install the platform package explicitly: npm i @typescript/native-preview-<platform>-<arch> (e.g. -darwin-arm64, -linux-x64, -win32-x64)","Verify your platform has a published prebuilt; if unsupported, there is no local workaround - use the JS TypeScript compiler instead","Clear the package manager cache and reinstall if node_modules looks truncated","Ensure Node >= 18.19 so import.meta.resolve exists (the fallback require.resolve path is Node 16 only)"],"exampleFix":"# before\nnpm install --omit=optional @typescript/native-preview\n\n# after\nnpm install --include=optional @typescript/native-preview\n# or pin the platform binary explicitly\nnpm i @typescript/native-preview-linux-x64","handlingStrategy":"validation","validationCode":"// Verify the platform package is resolvable before calling getExePath()\nconst platformPkg = `@typescript/native-preview-${process.platform}-${process.arch}`;\nlet ok = false;\ntry { require.resolve(platformPkg + '/package.json'); ok = true; } catch {}\nif (!ok) throw new Error(`${platformPkg} is not installed - install with --include=optional`);","typeGuard":null,"tryCatchPattern":"try {\n    exe = getExePath();\n} catch (e) {\n    if (e instanceof Error && e.message.includes('Unable to resolve')) {\n        // actionable install fix: pull the platform package explicitly\n        console.error(`npm i ${platformPkg} (or reinstall with --include=optional)`);\n    } else throw e;\n}","preventionTips":["Never install with --omit=optional when using native toolchains","Assert platform support (os/arch matrix) in your setup script before install","Pin Node >= 18.19 so import.meta.resolve-based resolution works"],"tags":["npm","optional-dependencies","platform","installation","native-preview"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}