← All tools

ehmicky/nvexeca

Popularity 65 Updated Development & Build

nvm + execa = nvexeca

githubauto-collected

Installation

A directly usable install command is not verified yet. Check the project documentation or releases.

<picture <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ehmicky/design/main/nve/nvedark.svg"/ <img alt="nvexeca logo" src="https://raw.githubusercontent.com/ehmicky/design/main/nve/nve.svg" width="500"/ </picture

nvm + execa = nvexeca.

Execa improves child processes execution with a promise interface, cross-platform support, local binaries, interleaved output, and more.

nvexeca is a thin wrapper around Execa to run any file or command using any Node.js version.

Unlike nvm exec it:

  • 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 node nor npm global binaries. To run a specific Node.js version for an entire project or shell session, please use nvm, nvm-windows, n or nvs instead.

Example

import nvexeca from 'nvexeca'

const { childProcess, versionRange, version } = await nvexeca('8', 'node', [
  '--version',
])
console.log(`Node ${versionRange} (${version})`) // Node 8 (8.16.2)
const { exitCode, stdout, stderr } = await childProcess
console.log(`Exit code: ${exitCode}`) // 0
console.log(stdout) // v8.16.2

Install

npm install nvexeca

node =18.18.0 must be installed. However the command run by nvexeca can use any Node version (providing it is compatible with it).

This package is an ES module and must be loaded using an import or import() statement, not require(). If TypeScript is used, it must be configured to output ES modules, not CommonJS.

To use this as a CLI instead, please check nve.

Usage

nvexeca(versionRange, command, args?, options?)

Executes command ...args with a specific Node.js versionRange.

Arguments