bootstrap/specs/nodejs/template/README.md

1.3 KiB

NodeJS Flake Template

This is a template for constructing a working environment for Node.js development (version v18.18.2) with the npm (version 9.8.1) packaging tool. direnv can be used to launch a dev shell upon entering this directory (refer to .envrc). Otherwise run via:

$ nix develop

Building

If you make changes to the package-lock.json file, you'll need to update the npmDepsHash value in flake.nix. The easiest way to discover this value is by running the following:

$ prefetch-npm-deps package-lock.json

Alternatively, you can set the value of npmDepsHash to lib.fakeHash and run:

$ nix build

Nix will complain with the hash value it actually expected.

Language Server

The typescript-language-server (version 4.1.2) is included in this flake.

Formatting

Formatting depends on prettier (version 3.1.0). A pre-commit hook is included in .githooks that can be used to format all *.jsx? and *.tsx? files prior to commit. Install via:

$ git config --local core.hooksPath .githooks/

If running direnv, this hook is installed automatically when entering the directory.