Skip to content
Myr

node.md

This file

Path

docs/node.md

43 lines · 1.1 KiB · Markdown

Last changed by

Move API reference to its own page (#996)ehmickybefore adoption7cde496

History of this file

Take it

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 1–28why, one step back
1<picture>
2 <source media="(prefers-color-scheme: dark)" srcset="../media/logo_dark.svg">3 <img alt="execa logo" src="../media/logo.svg" width="400">4</picture>5<br>67# 🐢 Node.js files89## Run Node.js files1011```js12import {execaNode, execa} from 'execa';1314await execaNode('file.js');15// Is the same as:16await execa('file.js', {node: true});17// Or:18await execa('node', ['file.js']);19```2021## Node.js [CLI flags](https://nodejs.org/api/cli.html#options)2223```js24await execaNode('file.js', {nodeOptions: ['--no-warnings']});25```2627## Node.js version28

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 29why, one step back
29[`get-node`](https://github.com/ehmicky/get-node) and the [`nodePath`](api.md#optionsnodepath) option can be used to run a specific Node.js version. Alternatively, [`nvexeca`](https://github.com/ehmicky/nvexeca) or [`nve`](https://github.com/ehmicky/nve) can be used.

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 30–43why, one step back
30
31```js32import {execaNode} from 'execa';33import getNode from 'get-node';3435const {path: nodePath} = await getNode('16.2.0');36await execaNode('file.js', {nodePath});37```3839<hr>4041[**Next**: 🌐 Environment](environment.md)\42[**Previous**: 📜 Scripts](scripts.md)\43[**Top**: Table of contents](../readme.md#documentation)