Generating static assets the frontend build - alphagov/notifications-manuals GitHub Wiki
Generating static assets - the frontend build
Getting Started
Installing Node
brew install node
NPM is Node's package management tool. nvm
is a tool for managing different versions of NodeJS. Follow the guidance on nvm's github repository to install it.
Once installed, run the following to switch to the version of NodeJS for this project. If you don't have that version, it should tell you how to install it.
nvm use
Installing NPM packages
npm install
This is generally used when working on the JavaScript or other frontend components of a project.
Notify JavaScript projects all use a package-lock.json
file. Running npm install
will install dependencies listed in this file.
Changing package.json
before running npm install
will install the new or updated dependencies and write the change to the dependency tree to package-lock.json
. Changes to both files should be committed.
npm ci
Modern versions of NPM introduce npm ci
. This can be used in CI & test environments when a clean installation of all packages using the exact versions specified in package-lock.json
is required.
If there is any discrepancy in dependency versions between package.json
and package-lock.json
the install will fail.
Updating the project Node version
Edit the respective node
version specified in the .nvmrc
file.
Run nvm install
to install the new Node version.
The version specified in the .nvmrc
file is also used to select the Node version used in CI builds:
- Creating a PR with an updated version will build the PR using that version
- Merging a version change will build and deploy the frontend assets using the new version
Ensure that an LTS Node version is specified. This will also ensure the corresponding LTS NPM version is also installed.