hcengineering/platform · error

Unexpected exception: could not detect node path

Error message

Unexpected exception: could not detect node path

What it means

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.

Source

Thrown at foundations/utils/common/scripts/install-run.js:746

    }
    else {
        throw result.error || new Error('An unknown error occurred.');
    }
}
function runWithErrorAndStatusCode(logger, fn) {
    process.exitCode = 1;
    try {
        const exitCode = fn();
        process.exitCode = exitCode;
    }
    catch (e) {
        logger.error('\n\n' + e.toString() + '\n\n');
    }
}
function _run() {
    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;
    if (!nodePath) {
        throw new Error('Unexpected exception: could not detect node path');
    }
    if (path__WEBPACK_IMPORTED_MODULE_3__.basename(scriptPath).toLowerCase() !== 'install-run.js') {
        // If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control
        // to the script that (presumably) imported this file
        return;
    }
    if (process.argv.length < 4) {
        console.log('Usage: install-run.js <package>@<version> <command> [args...]');
        console.log('Example: install-run.js qrcode@1.2.2 qrcode https://rushjs.io');
        process.exit(1);
    }
    const logger = { info: console.log, error: console.error };
    runWithErrorAndStatusCode(logger, () => {
        const rushJsonFolder = findRushJsonFolder();
        const rushCommonFolder = _ensureAndJoinPath(rushJsonFolder, 'common');
        const packageSpecifier = _parsePackageSpecifier(rawPackageSpecifier);
        const name = packageSpecifier.name;
        const version = _resolvePackageVersion(logger, rushCommonFolder, packageSpecifier);

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Reinstall or repair Node so process.argv[0] resolves to the node binary (node -p process.argv[0]).
  2. Run the script directly via node <path>/install-run-rush.js ... instead of a custom wrapper.
  3. Ensure shebang-based execution uses a real node binary (which node points to a working install).

Example fix

// before
myCustomRuntime install-run-rush.js install   // argv[0] empty -> throws
// after
node common/scripts/install-run-rush.js install
Defensive patterns

Strategy: validation

Validate before calling

if (!process.argv[0]) throw new Error('node executable path missing from argv; run via node directly')

Prevention

When it happens

Trigger: 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).

Common situations: Custom Node builds or embedded V8 launches; wrapper scripts that strip argv; broken node installation where the executable path cannot be resolved.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/e5eb3c9da3b39548. Report an issue: GitHub.