# Node.js Essentials

Common built-ins and patterns.

```js
node file.js                      // run a script
node -v                           // version

// ES modules (package.json: "type": "module")
import { readFile } from "node:fs/promises";
import path from "node:path";
const text = await readFile("file.txt", "utf8");
path.join("a", "b", "c.txt");  path.resolve("x");  path.extname("a.txt");

process.argv.slice(2);            // CLI arguments
process.env.NODE_ENV;             // environment variables
process.exit(1);                  // exit with failure

// CommonJS
const fs = require("fs");
module.exports = { fn };
```
