nvm + execa = nvexeca.
nvexeca is a thin wrapper around Execa to run any file or command using any Node.js version.
- is run programmatically
- does not need a separate installation step for each Node version
- can run the major release's latest minor/patch version automatically
- does not require Bash
- is installed as a Node module
- works on Windows. No need to run as Administrator.
nvexeca executes a single file or command. It does not change the
npm global binaries. To run a specific Node.js version for an entire
project or shell session, please use
const nvexeca =const childProcess versionRange version = awaitconsole // Node 8 (8.16.2)const exitCode stdout stderr = await childProcessconsole // 0console // v8.16.2
npm install nvexeca
node >=10.17.0 must be installed. However the command run by
nvexeca can use
any Node version (providing it is compatible with it).
To use this as a CLI instead, please check
nvexeca(versionRange, command, args?, options?)
versionRange can be any version range
<12, or one of the following aliases:
latest: Latest available Node version
lts: Latest LTS Node version
global: Global Node version
local: Current directory's Node version
command is the file or command to execute.
args are the arguments passed to
command must be compatible with the specific Node
versionRange. For example
only compatible with Node
Both global and local binaries can be executed.
All Execa options are available. Please refer to Execa for the list of possible options.
The following options are also available.
Do not execute the command. This can be used to cache the initial Node.js binary download.
Whether to show a progress bar when the Node binary is downloading.
Base URL to retrieve Node binaries. Can be overridden (for example
The following environment variables can also be used:
The list of available Node.js versions is cached for one hour by default. If the
fetch option is:
true: the cache will not be used
false: the cache will be used even if it's older than one hour
Node.js binary's CPU architecture. This is useful for example when you're on x64 but would like to run Node.js x32.
All the values from
Current working directory of the child process.
When using the
local alias, this
also starts looking for a Node.js version file from this directory.
undefined when the
dry option is
Node.js version passed as input, such as
Normalized Node.js version. For example if
"v10" was passed as input,
version will be
File or command that was executed.
Arguments that were passed to the
The first time
nvexeca is run with a new
VERSION, the Node binary is
downloaded under the hood. This initially takes few seconds. However subsequent
runs are almost instantaneous.
If your code is using native modules,
nvexeca works providing:
- they are built with N-API
- the target Node.js version is
>=8.12.0(since N-API was not available or stable before that)
Otherwise the following error message is shown:
Error: The module was compiled against a different Node.js version.
nvexecaas a CLI
execa: Process execution for humans
get-node: Download Node.js
preferred-node-version: Get the preferred Node.js version of a project or user
node-version-alias: Resolve Node.js version aliases like
normalize-node-version: Normalize and validate Node.js versions
all-node-versions: List all available Node.js versions
fetch-node-website: Fetch releases on nodejs.org
global-cache-dir: Get the global cache directory
If you found a bug or would like a new feature, don't hesitate to submit an issue on GitHub.
For other questions, feel free to chat with us on Gitter.
Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.
This project was made with ❤️. The simplest way to give back is by starring and sharing it online.
If the documentation is unclear or has a typo, please click on the page's
button (pencil icon) and suggest a correction.
If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!
💻 🎨 🤔 📖