{"record":{"id":"fd33cd476a3ab45a","repo":"hcengineering/platform","slug":"unexpected-exception-could-not-detect-node-path-o-fd33cd","errorCode":null,"errorMessage":"Unexpected exception: could not detect node path or script path","messagePattern":"Unexpected exception: could not detect node path or script path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/common/scripts/install-run-rush.js","lineNumber":165,"sourceCode":"}\nfunction _getBin(scriptName) {\n    switch (scriptName.toLowerCase()) {\n        case 'install-run-rush-pnpm.js':\n            return 'rush-pnpm';\n        case 'install-run-rushx.js':\n            return 'rushx';\n        default:\n            return 'rush';\n    }\n}\nfunction _run() {\n    const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;\n    // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the\n    // appropriate binary inside the rush package to run\n    const scriptName = path__WEBPACK_IMPORTED_MODULE_0__.basename(scriptPath);\n    const bin = _getBin(scriptName);\n    if (!nodePath || !scriptPath) {\n        throw new Error('Unexpected exception: could not detect node path or script path');\n    }\n    let commandFound = false;\n    let logger = { info: console.log, error: console.error };\n    for (const arg of packageBinArgs) {\n        if (arg === '-q' || arg === '--quiet') {\n            // The -q/--quiet flag is supported by both `rush` and `rushx`, and will suppress\n            // any normal informational/diagnostic information printed during startup.\n            //\n            // To maintain the same user experience, the install-run* scripts pass along this\n            // flag but also use it to suppress any diagnostic information normally printed\n            // to stdout.\n            logger = {\n                info: () => { },\n                error: console.error\n            };\n        }\n        else if (!arg.startsWith('-') || arg === '-h' || arg === '--help') {\n            // We either found something that looks like a command (i.e. - doesn't start with a \"-\"),","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/common/scripts/install-run-rush.js#L147-L183","documentation":"The _run bootstrap in install-run-rush.js destructures process.argv expecting [nodePath, scriptPath, ...args]. If node or the script path is missing from argv (which should never happen under normal node execution), it throws this error because it cannot determine which rush binary to run.","triggerScenarios":"process.argv has fewer than 2 entries when install-run-rush.js executes — e.g. the script is embedded/executed in an environment that strips argv (custom embedders, bundled workers, unusual spawnSync with empty args array).","commonSituations":"Invoking the script via a non-standard runner or embedding tool that rewrites argv; spawning node with an argv array that omits the script path; tooling that concatenates scripts and drops the entry argv.","solutions":["Invoke the script normally: node common/scripts/install-run-rush.js <rush-args> so argv includes node path and script path.","If spawning programmatically, ensure the argv array is [nodeExe, scriptPath, ...args] and not empty.","Check for wrappers/patches that modify process.argv before this script runs and restore the defaults.","Call rush install/build directly (globally installed rush) to bypass the bootstrap script."],"exampleFix":"// before\nspawnSync('node', [], { shell: true }) // argv empty -> error\n// after\nspawnSync(process.execPath, [path.join(__dirname, 'install-run-rush.js'), 'build'], { stdio: 'inherit' })","handlingStrategy":"validation","validationCode":"if (process.argv.length < 2 || !process.argv[1].endsWith('install-run-rush.js')) {\n  throw new Error('Script must be invoked as: node install-run-rush.js <args>')\n}","typeGuard":"function invokedAsScript(argv: string[]): boolean {\n  return Array.isArray(argv) && argv.length >= 2 &&\n    Boolean(argv[0]) && Boolean(argv[1])\n}","tryCatchPattern":null,"preventionTips":["Always run the bootstrap via its npm script alias (npm run rush / rushx) rather than embedding it.","When spawning programmatically, always pass [process.execPath, scriptPath, ...args].","Do not patch or reorder process.argv globally in wrappers that also run bootstrap scripts.","Test custom runners with a trivial spawn to confirm argv[0]/argv[1] are populated."],"tags":["build-tooling","rush","process-argv"],"backgroundTag":"missing-process-argv","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}