microsoft/typescript-go · error · Error

package-lock.json does not contain ${npmPackageName}; run np

Error message

package-lock.json does not contain ${npmPackageName}; run npm install.

What it means

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.

Source

Thrown at Herebyfile.mjs:2274

    const dest = path.join(builtPublishedPlatformPackages, "node_modules", ...npmPackageName.split("/"));
    const lib = path.join(dest, "lib");
    if (fs.existsSync(lib)) {
        return lib;
    }

    await fs.promises.mkdir(dest, { recursive: true });

    const tarballDestination = path.join(builtPublishedPlatformPackages, "tarballs");
    await fs.promises.mkdir(tarballDestination, { recursive: true });

    const version = getPublishedTypeScriptPackageJson().optionalDependencies[npmPackageName];
    if (!version || typeof version !== "string") {
        throw new Error(`${publishedTypeScriptAliasPackageName} does not depend on ${npmPackageName}.`);
    }

    const lockEntry = getPackageLock().packages[`node_modules/${npmPackageName}`];
    if (!lockEntry) {
        throw new Error(`package-lock.json does not contain ${npmPackageName}; run npm install.`);
    }
    if (lockEntry.version !== version) {
        throw new Error(`package-lock.json has ${npmPackageName}@${lockEntry.version}, but ${publishedTypeScriptAliasPackageName} depends on ${version}.`);
    }
    if (!lockEntry.resolved || typeof lockEntry.resolved !== "string") {
        throw new Error(`package-lock.json entry for ${npmPackageName}@${version} does not contain a tarball URL.`);
    }

    console.log(`Fetching ${npmPackageName}@${version} with npm.`);
    const { stdout } = await $pipe({ cwd: tarballDestination, env: releasePackageEnv })`npm pack --json ${npmPackageName}@${version}`;
    const [packed] = JSON.parse(stdout);
    if (!packed.filename || typeof packed.filename !== "string") {
        throw new Error(`npm pack ${npmPackageName}@${version} did not return a filename.`);
    }
    await tar.x({ file: path.join(tarballDestination, packed.filename), cwd: dest, strip: 1 });

    if (!fs.existsSync(lib)) {
        throw new Error(`Published platform package ${npmPackageName}@${version} did not contain a lib directory.`);

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Re-run `npm install` at the repo root so package-lock.json gains the `node_modules/<npmPackageName>` entry, then retry
  2. Verify the entry exists afterwards: `node -p "require('./package-lock.json').packages['node_modules/<name>']"`
  3. Commit the updated lockfile so other machines don't hit the same gap
Defensive patterns

Strategy: validation

Validate before calling

const lock = require("./package-lock.json");
const entry = lock.packages[`node_modules/${npmPackageName}`];
if (!entry) {
  throw new Error(`package-lock.json missing ${npmPackageName} — run npm install and commit the lock`);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/9f7dc1782e4b3321. Report an issue: GitHub.