{"record":{"id":"5549eef64ee5446e","repo":"hcengineering/platform","slug":"unexpected-exception-could-not-detect-node-path-o-5549ee","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":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/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/core/common/scripts/install-run-rush.js#L147-L183","documentation":"_run destructures process.argv expecting argv[0] to be the node executable and argv[1] to be this script's path. If either is missing/empty, it cannot determine which rush binary (rush vs rushx) to launch and throws immediately before doing any work.","triggerScenarios":"Invoking install-run-rush.js in an environment where process.argv lacks the node path or script path (e.g. embedded/custom runtime, unusual embedding where argv was trimmed or replaced).","commonSituations":"Running the script through a wrapper that mangles argv; exotic execution contexts (embedded V8, custom REPL) rather than a normal `node install-run-rush.js ...` invocation.","solutions":["Invoke the script normally: node common/scripts/install-run-rush.js <args> so argv contains node path and script path","Fix any wrapper/bootstrap that strips or rewrites process.argv before requiring the script","Update your Node runtime if a broken custom runner is trimming argv"],"exampleFix":"// before\nnode -e \"require('./common/scripts/install-run-rush.js')\" build\n// after\nnode common/scripts/install-run-rush.js build","handlingStrategy":"try-catch","validationCode":"if (process.argv.length < 2 || !process.argv[0] || !process.argv[1]) throw new Error('Script must be run directly via node: node install-run-rush.js <args>');","typeGuard":null,"tryCatchPattern":"try { runRushLauncher(); }\ncatch (e) { if (/could not detect node path or script path/.test(e.message)) { console.error('Invoke via: node common/scripts/install-run-rush.js <args>'); } else throw e; }","preventionTips":["Always execute the script directly with node, not via embedded/wrapper runtimes","Avoid wrappers that rewrite or trim process.argv","Test bootstrap scripts after changing CI runner images"],"tags":["node","argv","bootstrapping"],"backgroundTag":"missing-node-runtime-path","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}