{"record":{"id":"7a7e4d8ff0277df3","repo":"LykosAI/StabilityMatrix","slug":"runnpm-with-args-args-failed-with-exit-code-process-exitcode","errorCode":null,"errorMessage":"RunNpm with args [{args}] failed with exit code {process.ExitCode}:\n{stdOut}\n{stdErr}","messagePattern":"RunNpm with args \\[(.+?)\\] failed with exit code (.+?):\n(.+?)\n(.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs","lineNumber":456,"sourceCode":"        );\n\n        await process.WaitForExitAsync();\n\n        if (process.ExitCode == 0)\n            return;\n\n        var stdOut = await process.StandardOutput.ReadToEndAsync();\n        var stdErr = await process.StandardError.ReadToEndAsync();\n\n        Logger.Error(\n            \"RunNpm with args [{Args}] failed with exit code \" + \"{ExitCode}:\\n{StdOut}\\n{StdErr}\",\n            args,\n            process.ExitCode,\n            stdOut,\n            stdErr\n        );\n\n        throw new ProcessException(\n            $\"RunNpm with args [{args}] failed with exit code\" + $\" {process.ExitCode}:\\n{stdOut}\\n{stdErr}\"\n        );\n    }\n\n    public AnsiProcess RunNpmDetached(\n        ProcessArgs args,\n        string? workingDirectory = null,\n        Action<ProcessOutput>? onProcessOutput = null,\n        IReadOnlyDictionary<string, string>? envVars = null\n    )\n    {\n        return ProcessRunner.StartAnsiProcess(\n            NpmPath,\n            args,\n            workingDirectory,\n            onProcessOutput,\n            envVars ?? new Dictionary<string, string>()\n        );","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs#L438-L474","documentation":"RunNpm launches npm (for A3/ComfyUI-Manager style package scripts) and throws ProcessException with args, exit code, stdout, and stderr whenever the process exits nonzero. It surfaces npm command failures to the package install/update flow.","triggerScenarios":"Any npm run via RunNpm exiting nonzero — npm not installed/wrong PATH, registry unreachable, dependency resolution (npm install) failure, or the invoked script itself erroring.","commonSituations":"Node/npm missing on Linux so PATH lookup fails; offline or rate-limited npm registry; peer-dependency conflicts during install; package's npm script failing due to code errors.","solutions":["Inspect the stdOut/stdErr in the exception to identify the npm failure and address it.","Ensure Node.js/npm are installed and on PATH (install via distro package or nvm).","Fix network/registry access (proxy config, npmrc registry mirror) and retry.","Clear the package's node_modules and lockfile and rerun the npm step."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var npmPath = which(\"npm\"); // e.g. ProcessRunner 'command -v npm'\nif (string.IsNullOrEmpty(npmPath)) throw new Exception(\"npm is required but not installed\");","typeGuard":null,"tryCatchPattern":"try { await helper.RunNpm(args); }\ncatch (ProcessException ex)\n{ logger.Error(ex, \"npm step failed; see stdout/stderr in message\"); }","preventionTips":["Install Node.js/npm (via distro packages or nvm) before package installs that need it.","Configure npm registry/proxy access in .npmrc.","Clear node_modules and lockfiles after dependency resolution failures.","Keep Node at a version the package supports."],"tags":["npm","nodejs","process-exit-code","linux","package-install"],"backgroundTag":"command-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}