apache/beam · error

result.output (dynamic npm pack failure output)

Error message

result.output (dynamic npm pack failure output)

What it means

runPipelineWithProto shells out to npm pack to build the dependency bundle. If the npm process exits non-zero, the function throws with the combined command output (result.output). The message text is dynamic — the raw stdout/stderr of the failed npm pack.

Solutions

  1. Read the thrown output to find the npm error, then fix the underlying package.json/dependency issue it names.
  2. Verify npm is installed and on PATH (npm --version) in the environment submitting the pipeline.
  3. Check network/registry access (npm config get registry; proxy settings) if the output shows fetch failures.
  4. Ensure the temp/staging directory is writable and has enough disk space.
Defensive patterns

Strategy: try-catch

Validate before calling

try { require('child_process').execSync('npm --version'); } catch { throw new Error('npm is required to submit portable TypeScript pipelines'); }

Try / catch

try {
  await runner.runPipelineWithProto(proto);
} catch (e) {
  console.error('npm pack failed:', (e as Error).message); // message is the npm output
  // fix package.json / npm availability / registry access, then retry
}

Prevention

When it happens

Trigger: Spawning 'npm pack' during portable pipeline submission and getting a non-zero exit status: invalid package.json in the staged directory, missing npm on PATH, npm registry/network failures, or permission problems in tmpDir.

Common situations: No npm installed or wrong Node version in the runner environment; broken dependencies in the pipeline's package.json; corporate proxy/registry blocking npm; read-only temp directories.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/f3eafb7335872e56. Report an issue: GitHub.

Appendix: source

Thrown at sdks/typescript/src/apache_beam/runners/portable_runner/runner.ts:252

              env,
              (options as any)?.sdkContainerImage ||
                DOCKER_BASE + ":" + beamVersion.replace("-SNAPSHOT", ".dev"),
            );
          const deps = pipeline.components!.environments[envId].dependencies;

          // Package up this code as a dependency.
          const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "beam-pack-"));
          const result = childProcess.spawnSync(
            "npm",
            ["pack", "--pack-destination", tmpDir],
            {
              encoding: "latin1",
            },
          );
          if (result.status === 0) {
            console.debug(result.stdout);
          } else {
            throw new Error(result.output);
          }
          const packFile = path.resolve(
            path.join(tmpDir, result.stdout.trim()),
          );
          deps.push(fileArtifact(packFile, "beam:artifact:type:npm:v1"));

          // If any dependencies are files, package them up as well.
          if (fs.existsSync("package.json")) {
            const packageData = JSON.parse(fs.readFileSync("package.json"));
            if (packageData.dependencies) {
              for (const dep in packageData.dependencies) {
                if (packageData.dependencies[dep].startsWith("file:")) {
                  const path = packageData.dependencies[dep].substring(5);
                  deps.push(
                    fileArtifact(
                      path,
                      "beam:artifact:type:npm_dep:v1",
                      new TextEncoder().encode(dep),

View on GitHub (pinned to 12126d8942)