Preview the next version of the node buildpack: yoga. It's the most powerful and flexible Node buildpack yet.
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#yoga
git commit -am 'yoga' --allow-empty
git push heroku masterIt's still in beta and we'd love feedback!
- Specify an npm version
- Enable or disable node_modules caching
- Enable or disable devDependencies installation
- Configure npm with .npmrc
- Chain node with multiple buildpacks
Yoga also outputs minimal but useful messages on success and concise debug information on error. No more 20,000-line error logs!
Set engines.node in package.json to the semver range (or specific version) of node you'd like to use. (It's a good idea to make this the same version you use during development)
"engines": {
"node": "0.11.x"
}"engines": {
"node": "0.10.33"
}Default: the latest stable version.
Set engines.npm in package.json to the semver range (or specific version) of npm you'd like to use. (It's a good idea to make this the same version you use during development)
Since 'npm 2' shipped several major bugfixes, you might try:
"engines": {
"npm": "2.x"
}"engines": {
"npm": "^2.1.0"
}Default: the version of npm bundled with your node install (varies).
For a 'clean' build without using any cached node modules:
heroku config:set NODE_MODULES_CACHE=false
git commit -am 'rebuild' --allow-empty
git push heroku master
heroku config:unset NODE_MODULES_CACHECaching node_modules between builds dramatically speeds up build times.
However, npm install doesn't automatically update already-installed modules
as long as they fall within acceptable semver ranges,
which can lead to outdated modules.
Default: NODE_MODULES_CACHE defaults to true
During local development, npm install installs all dependencies
and all devDependencies (test frameworks, build tools, etc).
This is usually something you want to avoid in production, so
npm has a 'production' config that can be set through the environment:
To install dependencies only:
heroku config:set NPM_CONFIG_PRODUCTION=trueTo install dependencies and devDependencies:
heroku config:set NPM_CONFIG_PRODUCTION=falseDefault: NPM_CONFIG_PRODUCTION defaults to true on Heroku
Sometimes, a project needs custom npm behavior to set up proxies,
use a different registry, etc. For such behavior,
just include an .npmrc file in the root of your project:
# .npmrc
registry = 'https://custom-registry.com/'
Frequently, Node is paired with other platforms like Ruby or PHP
through Heroku's Multi Buildpack. In order to use node in
another environment, specify this buildpack first in your .buildpacks file.
This buildpack automatically exports node, npm, and any node_modules binaries
into the $PATH for easy use in subsequent buildpacks.
The next features in the pipeline include:
- Specifying io.js as your node engine
- Providing proxy settings for your locked-down enterprise environment
- Dynamically adjusting to different container sizes (especially regarding memory)
Having trouble? Dig it? Feature request?
Anvil is a generic build server for Heroku.
gem install anvil-cli
The heroku-anvil CLI plugin is a wrapper for anvil.
heroku plugins:install https://github.com/ddollar/heroku-anvil
The ddollar/test buildpack runs bin/test on your app/buildpack.
heroku build -b ddollar/test # -b can also point to a local directory
For more info on testing, see Best Practices for Testing Buildpacks on the Heroku discussion forum.