Using NodeJS and NPM with the DeployHQ Build Pipeline

Tips & Tricks

Many websites take advantage of specific frameworks and runtimes to help with development. One such technology is Node.js, which is an open source JavaScript runtime.

Deploying Node.js projects

To be able to deploy a Node.js web app, you'll need to use a tool to compile any assets that have been prepared, so that they can be understood by web servers and client browsers. A very popular technology for doing so, is NPM.

NPM allows developers to not only compile prepared assets, but also fetch external dependencies that might be required. Generally a simple process of install then build to gather the appropriate dependencies before building. This is normally defined in a package.json file.

Using the Build Pipeline to build your project

When creating a build command, if you select the NPM option, the most commonly commands will be entered for you, these are:

npm install --quiet
npm run build

However, if you use different commands to run your project locally, you can edit/update these using the textbox provided.

Configuring the build languages for specific Node versions

By default, your build commands will run using the latest supported version of Node, however, if your project requires a specific version, you can configure this under “Build Pipeline > Build Configuration”.

Using the Build Cache to speed up the build

Build commands may include fetching dependencies using NPM, which can take some time to complete. Caching these files would allow for them to not need to be downloaded during every deployment. Within “Cached Build Files” you can add an entry for each group of files/folders that you’d like to cache. The most common rules for node_modules are:


Adding Excluded Files to stop unwanted dependencies from being uploaded

Files generated within a build pipeline but not required to be uploaded to your server, can be excluded with excluded file rules. To add an excluded file, head to your project's Settings dropdown, then the Excluded Files option. Click to add a new excluded file, entering the full path of the file as the name. This will likely be the same entries as used for build cache rules.

A number of frameworks that use NPM/Node.js

We have a list of guides for a number of technologies that can utilise Node.js and NPM within the build pipeline:

  • Angular
  • Gatsby
  • Hexo
  • React
  • Vue

And as always, if you have any questions about using Node and NPM, or any other aspects of the DeployHQ service, do get in touch.

A little bit about the author

I'm Carla and I work in the support team for Krystal Labs and Dial 9. When I'm not helping customers with their questions I enjoy spending time with my dog and cats.

Proudly powered by Katapult. Running on 100% renewable energy.