Skip to content
Myr

node.md

This file

Path

docs/node.md

49 lines · 1.6 KiB · Markdown

Last changed by

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

History of this file

Take it

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 1–13why, 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';13

Improve `readme.md` (#999)ehmickybefore adoptionaca3db3

line 14why, one step back
14await execaNode`file.js argument`;

Add user guides (#989)ehmickybefore adoptionbe91ecf

line 15why, one step back
15// Is the same as:

Improve `readme.md` (#999)ehmickybefore adoptionaca3db3

line 16why, one step back
16await execa({node: true})`file.js argument`;

Add user guides (#989)ehmickybefore adoptionbe91ecf

line 17why, one step back
17// Or:

Improve `readme.md` (#999)ehmickybefore adoptionaca3db3

line 18why, one step back
18await execa`node file.js argument`;

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 19–20why, one step back
19```
20

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

line 21why, one step back
21## Node.js CLI flags

Add user guides (#989)ehmickybefore adoptionbe91ecf

line 22why, one step back
22

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

lines 23–26why, one step back
23When using the [`node`](api.md#optionsnode) option or [`execaNode()`](api.md#execanodescriptpath-arguments-options), the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) are inherited. For example, the subprocess will use [`--allow-fs-read`](https://nodejs.org/api/cli.html#--allow-fs-read) if the current process does.
2425The [`nodeOptions`](api.md#optionsnodeoptions) option can be used to set different CLI flags.26

Add user guides (#989)ehmickybefore adoptionbe91ecf

line 27why, one step back
27```js

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

line 28why, one step back
28await execaNode({nodeOptions: ['--allow-fs-write']})`file.js argument`;

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 29–31why, one step back
29```
3031## Node.js version

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

lines 32–33why, one step back
32
33The same applies to the Node.js version, which is inherited too.

Add user guides (#989)ehmickybefore adoptionbe91ecf

line 34why, one step back
34

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

line 35why, one step back
35[`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 36–41why, one step back
36
37```js38import {execaNode} from 'execa';39import getNode from 'get-node';4041const {path: nodePath} = await getNode('16.2.0');

Improve `readme.md` (#999)ehmickybefore adoptionaca3db3

line 42why, one step back
42await execaNode({nodePath})`file.js argument`;

Add user guides (#989)ehmickybefore adoptionbe91ecf

lines 43–49why, one step back
43```
4445<hr>4647[**Next**: 🌐 Environment](environment.md)\48[**Previous**: 📜 Scripts](scripts.md)\49[**Top**: Table of contents](../readme.md#documentation)