Snippets about node

8 snippets

Back to all snippets

  1. 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.

  2. SNP 122 #42A

    Load .env files in Node without a package

    dotenv is built into Node now.

  3. SNP 120 #593

    Reverse proxy a Node app with nginx

    Your app listens on 3000, the world talks to nginx on 443.

  4. SNP 104 #64B

    Run a Node app as a systemd service

    Start on boot, restart on crash, logs in journalctl. No pm2 needed.

  5. SNP 092 #A24

    Run TypeScript directly with Node

    No build step, no ts-node, for scripts and quick experiments.

  6. SNP 084 #45A

    __dirname in ES modules

    It's gone in ESM. Here is the replacement, and the newer, nicer one.

  7. SNP 038 #416

    Read a JSON file in Node

    Two ways, one of them without any fs code at all.

  8. 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.