node.md
This file
Path
docs/node.md
43 lines · 1.1 KiB · Markdown
Last changed by
Add user guides (#989)ehmickybefore adoptionbe91ecf
History of this fileTake it
Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 1–43why, 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');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 version2829[`get-node`](https://github.com/ehmicky/get-node) and the [`nodePath`](../readme.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.3031```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)