microsoft/typescript-go · error · Error

npm pack ${npmPackageName}@${version} did not return a filen

Error message

npm pack ${npmPackageName}@${version} did not return a filename.

What it means

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.

Source

Thrown at Herebyfile.mjs:2287

        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.`);
    }

    return lib;
}

async function runPackVsixExtensions() {
    await rimraf(builtVsix);
    await fs.promises.mkdir(builtVsix, { recursive: true });
    if (usePublishedPlatformPackagesForVsix) {
        checkPublishedPlatformPackagesForVsix();
        publishedPlatformPackageLibDirs.clear();
        await rimraf(builtPublishedPlatformPackages);
    }

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Reproduce manually: run `npm pack --json <npmPackageName>@<version>` in the tarballs dir and inspect the exact stdout to see what npm emitted
  2. Align the npm version with the one the release pipeline expects (Node LTS bundled npm)
  3. Remove any wrapper/config that writes to stdout during pack, and ensure registry auth is configured so pack succeeds
Defensive patterns

Strategy: try-catch

Validate before calling

// Smoke-test the toolchain shape once before the pipeline
const { stdout } = await $pipe`npm pack --json --dry-run <npmPackageName>@<version>`;
const [first] = JSON.parse(stdout);
if (!first || typeof first.filename !== "string") {
  throw new Error("npm pack --json output shape unexpected; pin a compatible npm version");
}

Try / catch

try {
  const [packed] = JSON.parse(stdout);
  if (!packed?.filename) throw new Error(`npm pack did not return a filename`);
  // proceed with extraction
} catch (e) {
  if (/did not return a filename/.test(String(e?.message))) {
    // log raw stdout for diagnosis, pin npm version, fail the run — do not silently retry
    throw new Error(`npm pack output unusable: ${stdout.slice(0, 500)}`);
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


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