Snippets about node
8 snippets
-
SNP 126
#A25
Pages from a CMS in Stati
Write the CMS's posts as Markdown before the build starts. A hook is too late.
-
SNP 122
#42A
Load .env files in Node without a package
dotenv is built into Node now.
-
SNP 120
#593
Reverse proxy a Node app with nginx
Your app listens on 3000, the world talks to nginx on 443.
-
SNP 104
#64B
Run a Node app as a systemd service
Start on boot, restart on crash, logs in journalctl. No pm2 needed.
-
SNP 092
#A24
Run TypeScript directly with Node
No build step, no ts-node, for scripts and quick experiments.
-
SNP 084
#45A
__dirname in ES modules
It's gone in ESM. Here is the replacement, and the newer, nicer one.
-
SNP 038
#416
Read a JSON file in Node
Two ways, one of them without any fs code at all.
-
SNP 036
#B63
Sleep in Node without writing a timeout function
Node ships a promise-based setTimeout, so the little helper from my old snippet isn't needed there.