Home

Awesome

Heroku Cloud Native Buildpacks: Node.js

Cloud Native Buildpacks Registry: heroku/nodejs CI on Github Actions: heroku/nodejs

Heroku Cloud Native Buildpack: heroku/nodejs

This repository is the home of Heroku Cloud Native Buildpacks for Node.js applications. These buildpacks build Node.js application source code into application images with minimal configuration.

[!IMPORTANT] This is a collection of Cloud Native Buildpacks, and is a component of the Heroku Cloud Native Buildpacks project, which is in preview. If you are instead looking for the Heroku Classic Buildpack for Node.js (for use on the Heroku platform), you may find it here.

Usage

[!NOTE] Before getting started, ensure you have the pack CLI installed. Installation instructions are available here.

To build a Node.js application codebase into a production image:

$ cd ~/workdir/sample-nodejs-app
$ pack build sample-app --builder heroku/builder:24

Then run the image:

docker run --rm -it -e "PORT=8080" -p 8080:8080 sample-app

Application Requirements

The heroku/nodejs buildpack requires a valid package.json to be present to build.

In order to install dependencies, a vaild npm, yarn, or pnpm lockfile must be present.

Configuration

Node.js Version

To select a Node.js version, specify it via engines.node in package.json.

For example, to select the latest releasse in the Node.js 20 line, modify your package.json like this:

{
  "engines": {
    "node": "20.x"
  }
}

This field supports the same semantic versioning syntax as package.json.

If no Node.js version is specified, the latest LTS version will be used. We highly suggest specifying a version to prevent surprise changes.

Included Buildpacks

This repository contains multiple buildpacks:

IDNameReadme
heroku/nodejsNode.js Composite BuildpackReadme
heroku/nodejs-engineNode.js Engine BuildpackReadme
heroku/nodejs-corepackCorepack BuildpackReadme
heroku/nodejs-npmnpm BuildpackReadme
heroku/nodejs-npm-enginenpm Engine BuildpackReadme
heroku/nodejs-npm-installnpm Install BuildpackReadme
heroku/nodejs-pnpm-installpnpm install BuildpackReadme
heroku/nodejs-yarnYarn BuildpackReadme

The heroku/nodejs composite buildpack is the recommended buildpack for most users and applications. It is a composite buildpack that contains the functionality of the independent buildpacks.

Contributing

Issues and pull requests are welcome. See our contributing guidelines if you would like to help.