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.
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:22
Then run the image:
docker run --rm -it -e "PORT=8080" -p 8080:8080 sample-app
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.
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.
This repository contains multiple buildpacks:
ID | Name | Readme |
---|---|---|
heroku/nodejs |
Node.js Composite Buildpack | Readme |
heroku/nodejs-engine |
Node.js Engine Buildpack | Readme |
heroku/nodejs-corepack |
Corepack Buildpack | Readme |
heroku/nodejs-npm |
npm Buildpack | Readme |
heroku/nodejs-npm-engine |
npm Engine Buildpack | Readme |
heroku/nodejs-npm-install |
npm Install Buildpack | Readme |
heroku/nodejs-pnpm-install |
pnpm install Buildpack | Readme |
heroku/nodejs-yarn |
Yarn Buildpack | Readme |
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.
Issues and pull requests are welcome. See our contributing guidelines if you would like to help.