{"record":{"id":"140e80d21569627b","repo":"hcengineering/platform","slug":"unexpected-exception-could-not-detect-node-path-o-140e80","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/utils/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/utils/common/scripts/install-run-rush.js#L147-L183","documentation":"The _run entrypoint of install-run-rush.js destructures process.argv expecting [nodePath, scriptPath, ...args]. If either nodePath or scriptPath is falsy — meaning the script was not invoked the normal way (node install-run-rush.js ...) — it throws this error before selecting the rush/rushx binary.","triggerScenarios":"Executing install-run-rush.js without a node interpreter in argv (e.g. chmod +x and running it directly without a shebang, or embedding it in a context that strips argv), so process.argv[1]/[2] are missing or empty.","commonSituations":"Invoking the script via a non-standard runner; copying the script into an environment where argv shape differs; calling it through a wrapper that mangles process.argv.","solutions":["Run the script with node explicitly: node common/scripts/install-run-rush.js <args>","Ensure a proper shebang (#!/usr/bin/env node) if executing it directly","Inspect process.argv in your wrapper to confirm nodePath and scriptPath are present"],"exampleFix":"// before\n./common/scripts/install-run-rush.js build --to myproject\n// after\nnode ./common/scripts/install-run-rush.js build --to myproject","handlingStrategy":"try-catch","validationCode":"if (process.argv.length < 2 || !process.argv[1]) {\n  throw new Error('install-run-rush.js must be run via node: node install-run-rush.js <args>')\n}","typeGuard":"null","tryCatchPattern":"try {\n  runRushScript()\n} catch (e) {\n  if (String(e.message).includes('could not detect node path or script path')) {\n    console.error('Invoke with: node common/scripts/install-run-rush.js <rush args>')\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Always invoke the script through node or keep its shebang intact","Do not wrap the script in runners that rewrite or truncate process.argv","Add a smoke CI job that runs `node common/scripts/install-run-rush.js -h`"],"tags":["rush","build-tooling","runtime"],"backgroundTag":"script-invocation-error","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}