Hmbown/CodeWhale · error · Error

npm pack did not return package metadata

Error message

npm pack did not return package metadata

What it means

Thrown by parsePackJson() when `npm pack --json` produced empty or whitespace-only stdout, so there is no package metadata to parse. Causes include npm failing silently, wrong working directory (no package to pack), or npm emitting output on stderr instead of stdout; the smoke test cannot identify the produced tarball without it.

Solutions

  1. Run `npm pack --json` manually in the intended directory to see what it prints
  2. Ensure the script runs in the package directory and that npm is on PATH and functional
  3. Check npm's stderr for the real failure; an npm error may have produced empty stdout
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at scripts/release/npm-wrapper-smoke.js:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/15739416ecea9ab5. Report an issue: GitHub.

Appendix: source

Thrown at scripts/release/npm-wrapper-smoke.js:127

    }
  });

  return new Promise((resolve, reject) => {
    server.once("error", reject);
    server.listen(0, "127.0.0.1", () => {
      const address = server.address();
      resolve({
        baseUrl: `http://127.0.0.1:${address.port}/`,
        server,
      });
    });
  });
}

function parsePackJson(stdout) {
  const trimmed = stdout.trim();
  if (!trimmed) {
    throw new Error("npm pack did not return package metadata");
  }
  const parsed = JSON.parse(trimmed);
  const first = Array.isArray(parsed) ? parsed[0] : parsed;
  if (!first || !first.filename) {
    throw new Error(`npm pack metadata did not include a filename: ${trimmed}`);
  }
  return first.filename;
}

async function removeSmokeWorkspace(tempRoot, remove = fsp.rm) {
  await remove(tempRoot, {
    force: true,
    recursive: true,
    // Windows can report ENOTEMPTY briefly while completed binary downloads
    // are still being released by the filesystem. fs.rm retries ENOTEMPTY
    // (and the other documented transient removal errors) with linear
    // backoff; the finite cap still surfaces a persistent cleanup failure.
    maxRetries: CLEANUP_MAX_RETRIES,

View on GitHub (pinned to 433685b202)