Run any command on specific Node.js versions.
nvm exec it:
- can run multiple Node.js versions at once
- can be run programmatically
- is 5 times faster
- does not need a separate installation step for each Node version
- can run the major release's latest minor/patch version automatically
- works on Windows. No need to run as Administrator.
- does not require Bash
- is installed as a Node module (as opposed to a Bash installation script downloaded with
nve 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
# Same as `node` but with Node 12 $ nve 12 node Welcome to Node.js v12.13.0. Type ".help" for more information. > .exit # Same as `node file.js` but with Node 8 $ nve 8 node file.js # Any command can be used $ nve 8 npm test # Execute a local binary $ nve 8 ava # Run a specific version $ nve 8.10.0 npm test # Run the latest Node version $ nve "*" npm test # Use a version range $ nve "<8" npm test # Use a different mirror for the Node binaries $ nve --mirror=https://npm.taobao.org/mirrors/node 8 npm test # Chaining commands $ nve 8 npm run build && nve 8 npm test # Cache Node 8 download $ nve 8 node --version
Examples (multiple versions)
# Run multiple versions $ nve 12 10 8 npm test ⬢ Node 12 105 tests passed Finished 'test' after 3.8 s ⬢ Node 10 105 tests passed Finished 'test' after 4.2 s ⬢ Node 8 105 tests passed Finished 'test' after 4.5 s # Do not abort on the first version that fails $ nve --continue 12 10 8 npm test # Run all versions in parallel $ nve --parallel 12 10 8 npm test # Cache multiple Node downloads $ nve 12 10 8 node --version
Examples (list versions)
# Prints latest Node.js version. Make sure you use quotes. $ nve "*" 13.1.0 # Prints latest Node.js 8 version $ nve 8 8.16.2 # Prints latest Node.js 12, 10 and 8 versions $ nve 12 10 8 12.13.0 10.17.0 8.16.2
You can try this library:
npm install -g nve
node >=10.17.0 must be globally installed. However the command run by
nve can use any Node version (providing it is compatible with it).
To use this programmatically (from Node.js) instead, please check
nve [OPTIONS...] VERSION... [COMMAND] [ARGS...]
This is exactly the same as:
But using specific Node
VERSION can be specified at once.
VERSION can be any version range such as
COMMAND must be compatible with the specific Node
VERSION. For example
npm is only compatible with Node
Both global and local binaries can be executed.
By default, when running multiple Node versions and one of those versions fails, the others are aborted. This option disables this.
When running multiple Node versions, run all of them at the same time. This is faster. However this does not work if the command:
- requires some interactive CLI input (for example using a prompt)
- is not concurrency-safe
Whether to show a progress bar while 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 first time
nve 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.
COMMAND can be omitted in order to cache that initial download without executing any commands.
Difference with nvm
nve is meant for one-off command execution. Examples include:
- running tests with an older Node.js version
- checking if an older Node.js version supports a specific syntax or feature
- benchmarking different Node.js versions
- programmatic usage or child processes
nve can (and probably should) be used alongside those tools.
If your code is using native modules,
nve 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.
nve: 199ms nvm exec: 1002ms npx node: 1343ms
nvebut programmatic (from Node.js)
execa: Process execution for humans
get-node: Download Node.js
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
If the documentation is unclear or has a typo, please click on the page's
Edit 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!
Thanks go to our wonderful contributors:
Charlike Mike Reagent
Pedro Augusto de Paula Barbosa