{"record":{"id":"e5eb3c9da3b39548","repo":"hcengineering/platform","slug":"unexpected-exception-could-not-detect-node-path-e5eb3c","errorCode":null,"errorMessage":"Unexpected exception: could not detect node path","messagePattern":"Unexpected exception: could not detect node path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/utils/common/scripts/install-run.js","lineNumber":746,"sourceCode":"    }\n    else {\n        throw result.error || new Error('An unknown error occurred.');\n    }\n}\nfunction runWithErrorAndStatusCode(logger, fn) {\n    process.exitCode = 1;\n    try {\n        const exitCode = fn();\n        process.exitCode = exitCode;\n    }\n    catch (e) {\n        logger.error('\\n\\n' + e.toString() + '\\n\\n');\n    }\n}\nfunction _run() {\n    const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, rawPackageSpecifier /* qrcode@^1.2.0 */, packageBinName /* qrcode */, ...packageBinArgs /* [-f, myproject/lib] */] = process.argv;\n    if (!nodePath) {\n        throw new Error('Unexpected exception: could not detect node path');\n    }\n    if (path__WEBPACK_IMPORTED_MODULE_3__.basename(scriptPath).toLowerCase() !== 'install-run.js') {\n        // If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control\n        // to the script that (presumably) imported this file\n        return;\n    }\n    if (process.argv.length < 4) {\n        console.log('Usage: install-run.js <package>@<version> <command> [args...]');\n        console.log('Example: install-run.js qrcode@1.2.2 qrcode https://rushjs.io');\n        process.exit(1);\n    }\n    const logger = { info: console.log, error: console.error };\n    runWithErrorAndStatusCode(logger, () => {\n        const rushJsonFolder = findRushJsonFolder();\n        const rushCommonFolder = _ensureAndJoinPath(rushJsonFolder, 'common');\n        const packageSpecifier = _parsePackageSpecifier(rawPackageSpecifier);\n        const name = packageSpecifier.name;\n        const version = _resolvePackageVersion(logger, rushCommonFolder, packageSpecifier);","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/utils/common/scripts/install-run.js#L728-L764","documentation":"The _run() entry point of install-run.js destructures process.argv, expecting argv[0] to be the node executable path. If nodePath is falsy, the runtime environment is so malformed that Node was started without a resolvable executable path, and the script refuses to continue. This is essentially a sanity check that should never fire in a normal Node process.","triggerScenarios":"Running the script with an exotic embedder/bundler where process.argv[0] is empty or undefined, or invoking the file in a non-Node environment (e.g. imported by tooling that rewrites argv).","commonSituations":"Custom Node builds or embedded V8 launches; wrapper scripts that strip argv; broken node installation where the executable path cannot be resolved.","solutions":["Reinstall or repair Node so process.argv[0] resolves to the node binary (node -p process.argv[0]).","Run the script directly via node <path>/install-run-rush.js ... instead of a custom wrapper.","Ensure shebang-based execution uses a real node binary (which node points to a working install)."],"exampleFix":"// before\nmyCustomRuntime install-run-rush.js install   // argv[0] empty -> throws\n// after\nnode common/scripts/install-run-rush.js install","handlingStrategy":"validation","validationCode":"if (!process.argv[0]) throw new Error('node executable path missing from argv; run via node directly')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always launch install-run scripts with a real node binary","Avoid custom runtime wrappers that rewrite process.argv","Verify node -p process.argv[0] prints a valid path in your environment"],"tags":["nodejs","cli","environment"],"backgroundTag":"missing-node-executable","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}