{"id":13620,"library":"node-exec-path","title":"Node Executable Path Helpers","description":"The `node-exec-path` package provides utilities for locating Node.js executable paths on a system and verifying if a particular Node.js installation satisfies a given semantic version range. It offers both synchronous (`satisfiesSemverSync`) and likely asynchronous (`satisfiesSemver`) methods to perform these checks. The current stable version is 1.2.1, though recent public release notes primarily show minor dependency upgrades, suggesting a focus on stability and maintenance rather than frequent new features. Its key differentiator is the direct integration of `semver` logic to programmatically identify suitable Node.js environments, which is crucial for applications that need to ensure compatibility with specific Node.js versions, especially in environments utilizing tools like `nvm` or `volta` where multiple Node.js installations coexist. This package abstracts away the complexities of searching `PATH` and parsing version strings.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/kmalakoff/node-exec-path","tags":["javascript","node","exec","path","satisfies","find","semver","typescript"],"install":[{"cmd":"npm install node-exec-path","lang":"bash","label":"npm"},{"cmd":"yarn add node-exec-path","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-exec-path","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for parsing and comparing Node.js versions to satisfy specified ranges.","package":"semver","optional":false}],"imports":[{"note":"The package ships TypeScript types and is designed for modern Node.js environments, favoring ESM imports. While CJS might work in some contexts, ESM is the recommended approach.","wrong":"const { satisfiesSemverSync } = require('node-exec-path');","symbol":"satisfiesSemverSync","correct":"import { satisfiesSemverSync } from 'node-exec-path';"},{"note":"Assumed asynchronous counterpart to 'satisfiesSemverSync', following common Node.js API patterns. Always prefer named imports for clarity.","wrong":"const satisfiesSemver = require('node-exec-path').satisfiesSemver;","symbol":"satisfiesSemver","correct":"import { satisfiesSemver } from 'node-exec-path';"}],"quickstart":{"code":"import { satisfiesSemverSync } from \"node-exec-path\";\n\n// Find a Node.js executable path that satisfies Node.js version >= 18.0\nconst execPath = satisfiesSemverSync(\">=18.0\");\n\nif (execPath) {\n  console.log(`Found compatible Node.js at: ${execPath}`);\n  // You can then use child_process.execFile to run scripts with this Node.js version\n  // import { execFile } from 'node:child_process';\n  // execFile(execPath, ['-v'], (error, stdout, stderr) => {\n  //   if (error) { console.error(error); return; }\n  //   console.log(`Version found: ${stdout.trim()}`);\n  // });\n} else {\n  console.log(\"No Node.js executable found satisfying '>=18.0'.\");\n}\n\n// Example with a different range\nconst node20Path = satisfiesSemverSync(\"~20.x\");\nif (node20Path) {\n  console.log(`Found Node.js ~20.x at: ${node20Path}`);\n}","lang":"typescript","description":"Demonstrates how to synchronously find a Node.js executable path that satisfies a specified semantic version range, returning the absolute path or null."},"warnings":[{"fix":"Ensure your system's PATH environment variable is ordered correctly or explicitly specify the desired Node.js version management tool's path before using `node-exec-path` if you need specific precedence.","message":"When multiple Node.js installations are present (e.g., via NVM, Volta, or system-wide installs), `node-exec-path` will return the first compatible executable it finds in the system's PATH. This might not always be the 'active' or desired version if not carefully managed by the user's environment setup.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If high performance is critical or for long-running processes, investigate if an asynchronous equivalent (like `satisfiesSemver`) is exposed by the library and use it to avoid blocking the event loop.","message":"The synchronous `satisfiesSemverSync` method can be blocking for I/O operations, especially if the system's PATH contains many directories or network drives, potentially impacting application responsiveness. Consider using asynchronous alternatives if available for performance-critical scenarios.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"When using the returned executable path with Node's `child_process` module, prefer `child_process.execFile` (which accepts the executable and arguments separately) over `child_process.exec` for robustness, or ensure proper quoting of paths with spaces if using `exec` with a shell.","message":"Path strings containing spaces (e.g., 'C:\\Program Files\\Nodejs\\node.exe') can be problematic when passed directly to `child_process.exec` without proper quoting or when relying on shell interpretation. While `node-exec-path` returns the path, users consuming it in `child_process` should be aware.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.1':53 'abstract':122 'applic':96 'asynchron':41 'away':123 'check':47 'coexist':119 'compat':101 'complex':125 'crucial':94 'current':49 'depend':62 'differenti':78 'direct':81 'ensur':100 'environ':91,108 'especi':106 'exec':8,135 'execut':2,16 'featur':75 'find':138 'focus':66 'frequent':73 'given':30 'helper':4 'identifi':88 'instal':27,118 'integr':82 'javascript':133 'key':77 'like':40,111 'locat':14 'logic':85 'mainten':70 'method':43 'minor':61 'multipl':116 'need':98 'new':74 'node':1,7,134 'node-exec-path':6 'node.js':15,26,90,104,117 'note':58 'nvm':112 'offer':35 'packag':10,121 'pars':130 'particular':25 'path':3,9,17,128,136 'perform':45 'primarili':59 'programmat':87 'provid':11 'public':56 'rang':33 'rather':71 'recent':55 'releas':57 'satisfi':28,137 'satisfiessemv':42 'satisfiessemversync':38 'search':127 'semant':31 'semver':84,139 'show':60 'specif':103 'stabil':68 'stabl':50 'string':132 'suggest':64 'suitabl':89 'synchron':37 'system':20 'though':54 'tool':110 'typescript':140 'upgrad':63 'util':12,109 'verifi':22 'version':32,51,105,131 'volta':114","created_at":"2026-04-20T01:55:26.922217+00:00","updated_at":"2026-04-20T01:55:26.922217+00:00","problems":[{"fix":"Run `npm install node-exec-path` or `yarn add node-exec-path` to install the package.","cause":"The 'node-exec-path' package is not installed or not accessible in the current project's `node_modules`.","error":"Error: Cannot find module 'node-exec-path'"},{"fix":"Ensure you are using `import { satisfiesSemverSync } from 'node-exec-path';` for ESM contexts. If in a CJS file, ensure `package.json` specifies `\"type\": \"module\"` or the library provides a CJS entry point.","cause":"This usually indicates an attempt to use a CommonJS `require()` statement or an incorrect default import for a package designed for named ESM imports.","error":"TypeError: (0, node_exec_path_1.satisfiesSemverSync) is not a function"},{"fix":"Provide a valid semantic version range string, for example, '>=18.0.0', '^16.x', '14.17.0 - 16.x', or similar. Refer to the `semver` documentation for valid range syntax.","cause":"The input string provided to `satisfiesSemverSync` (or other semver-related functions) does not conform to the semantic versioning specification.","error":"Invalid SemVer range: 'invalid-version-string'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kmalakoff/node-exec-path","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-exec-path","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}