node.md
This file
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1–49why, one step back1<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 argument`;15// Is the same as:16await execa({node: true})`file.js argument`;17// Or:18await execa`node file.js argument`;19```2021## Node.js CLI flags2223When 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.2627```js28await execaNode({nodeOptions: ['--allow-fs-write']})`file.js argument`;29```3031## Node.js version3233The same applies to the Node.js version, which is inherited too.3435[`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.3637```js38import {execaNode} from 'execa';39import getNode from 'get-node';4041const {path: nodePath} = await getNode('16.2.0');42await execaNode({nodePath})`file.js argument`;43```4445<hr>4647[**Next**: 🌐 Environment](environment.md)\48[**Previous**: 📜 Scripts](scripts.md)\49[**Top**: Table of contents](../readme.md#documentation)