{"record":{"id":"f3eafb7335872e56","repo":"apache/beam","slug":"result-output-dynamic-npm-pack-failure-output","errorCode":null,"errorMessage":"result.output (dynamic npm pack failure output)","messagePattern":"result\\.output \\(dynamic npm pack failure output\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/typescript/src/apache_beam/runners/portable_runner/runner.ts","lineNumber":252,"sourceCode":"              env,\n              (options as any)?.sdkContainerImage ||\n                DOCKER_BASE + \":\" + beamVersion.replace(\"-SNAPSHOT\", \".dev\"),\n            );\n          const deps = pipeline.components!.environments[envId].dependencies;\n\n          // Package up this code as a dependency.\n          const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), \"beam-pack-\"));\n          const result = childProcess.spawnSync(\n            \"npm\",\n            [\"pack\", \"--pack-destination\", tmpDir],\n            {\n              encoding: \"latin1\",\n            },\n          );\n          if (result.status === 0) {\n            console.debug(result.stdout);\n          } else {\n            throw new Error(result.output);\n          }\n          const packFile = path.resolve(\n            path.join(tmpDir, result.stdout.trim()),\n          );\n          deps.push(fileArtifact(packFile, \"beam:artifact:type:npm:v1\"));\n\n          // If any dependencies are files, package them up as well.\n          if (fs.existsSync(\"package.json\")) {\n            const packageData = JSON.parse(fs.readFileSync(\"package.json\"));\n            if (packageData.dependencies) {\n              for (const dep in packageData.dependencies) {\n                if (packageData.dependencies[dep].startsWith(\"file:\")) {\n                  const path = packageData.dependencies[dep].substring(5);\n                  deps.push(\n                    fileArtifact(\n                      path,\n                      \"beam:artifact:type:npm_dep:v1\",\n                      new TextEncoder().encode(dep),","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/typescript/src/apache_beam/runners/portable_runner/runner.ts#L234-L270","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the thrown output to find the npm error, then fix the underlying package.json/dependency issue it names.","Verify npm is installed and on PATH (npm --version) in the environment submitting the pipeline.","Check network/registry access (npm config get registry; proxy settings) if the output shows fetch failures.","Ensure the temp/staging directory is writable and has enough disk space."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try { require('child_process').execSync('npm --version'); } catch { throw new Error('npm is required to submit portable TypeScript pipelines'); }","typeGuard":null,"tryCatchPattern":"try {\n  await runner.runPipelineWithProto(proto);\n} catch (e) {\n  console.error('npm pack failed:', (e as Error).message); // message is the npm output\n  // fix package.json / npm availability / registry access, then retry\n}","preventionTips":["Install npm (Node.js) in the submission environment.","Validate package.json before submitting pipelines.","Ensure registry/proxy connectivity from CI environments.","Use a writable tmp dir with sufficient disk space."],"tags":["npm","packaging","subprocess","portable-runner"],"backgroundTag":"command-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}