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
node.md
🐢 Node.js files
Run Node.js files
import {execaNode, execa} from 'execa';
await execaNode('file.js');
// Is the same as:
await execa('file.js', {node: true});
// Or:
await execa('node', ['file.js']);
Node.js CLI flags
await execaNode('file.js', {nodeOptions: ['--no-warnings']});
Node.js version
get-node and the nodePath option can be used to run a specific Node.js version. Alternatively, nvexeca or nve can be used.
import {execaNode} from 'execa';
import getNode from 'get-node';
const {path: nodePath} = await getNode('16.2.0');
await execaNode('file.js', {nodePath});
Next: 🌐 Environment
Previous: 📜 Scripts
Top: Table of contents