The Node runtime
This part follows the program out of the type checker: the emitted JavaScript under Node.js, npm scripts, process.argv and process.env, fs, path and os, JSON files, dates, crypto random ids, timers and the exit code.
7.1
Run with Node
compile once, run the JavaScript with node, and read simple command line arguments
Open
7.2
npm scripts
build and start commands in the scripts map, run by name, chained with &&
Open
7.3
argv and env
process.argv, process.env and the default that keeps a setting safe
Open
7.4
Files with fs
read and write text files, round-trip JSON, and check a file exists first
Open
7.5
path and os
join path parts, find the folder of the script, and read a config location from os
Open
7.6
JSON IO
parse JSON into typed values, print it back, and guard a config against a bad shape
Open
7.7
Dates
dates, stable ISO strings, a difference between two stamps, and weekday names
Open
7.8
Crypto random
UUIDs and hex tokens from node crypto, and an id on each record
Open
7.9
Timers
setTimeout and setInterval, and the clear and unref that let a program end
Open
7.10
process
exit codes, a signal handled, and the directory and versions a program reads
Open