{"id":13716449,"url":"https://github.com/heroku/nodejs-npm-buildpack","last_synced_at":"2025-05-07T05:33:06.934Z","repository":{"id":258403400,"uuid":"208163360","full_name":"heroku/nodejs-npm-buildpack","owner":"heroku","description":"Heroku Cloud Native Buildpack for NPM on Node.js runtime","archived":true,"fork":false,"pushed_at":"2021-04-14T17:05:04.000Z","size":111,"stargazers_count":6,"open_issues_count":1,"forks_count":7,"subscribers_count":64,"default_branch":"main","last_synced_at":"2025-04-30T15:09:51.516Z","etag":null,"topics":["buildpack","cloud-native-buildpacks","nodejs","npm"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heroku.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-12T23:31:34.000Z","updated_at":"2024-11-20T14:16:03.000Z","dependencies_parsed_at":"2024-10-18T21:04:06.981Z","dependency_job_id":"01181392-0352-41cb-9869-705014cc0c45","html_url":"https://github.com/heroku/nodejs-npm-buildpack","commit_stats":null,"previous_names":["heroku/nodejs-npm-buildpack"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroku%2Fnodejs-npm-buildpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroku%2Fnodejs-npm-buildpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroku%2Fnodejs-npm-buildpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroku%2Fnodejs-npm-buildpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heroku","download_url":"https://codeload.github.com/heroku/nodejs-npm-buildpack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782573,"owners_count":21803404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buildpack","cloud-native-buildpacks","nodejs","npm"],"created_at":"2024-08-03T00:01:10.596Z","updated_at":"2025-05-07T05:33:06.632Z","avatar_url":"https://github.com/heroku.png","language":"Shell","funding_links":[],"categories":["[Heroku Buildpacks](https://devcenter.heroku.com/)"],"sub_categories":["Provides buildpacks for:"],"readme":"# Node.js NPM Cloud Native Buildpack (MOVED)\n\nThis repo has moved to https://github.com/heroku/buildpacks-node.\n\nThis buildpack builds on top of the existing [Node.js Engine Cloud Native Buildpack](https://github.com/heroku/nodejs-engine-buildpack). It runs subsequent scripts after Node is install.\n\n- Run automatically\n  - `npm install` or `npm ci`\n- Run when configured in `package.json`\n  - `npm run build` or `npm run heroku-postbuild`\n\n## Usage\n\n### Install pack\n\nUsing `brew` (assuming development is done on MacOS), install `pack`.\n\n```sh\nbrew tap buildpack/tap\nbrew install pack\n```\n\nIf you're using Windows or Linux, follow instructions [here](https://buildpacks.io/docs/install-pack/).\n\n### Install shpec (optional)\n\nThis buildpack uses `shpec` for unit tests, so to run them locally, you'll need to install the package.\n\n```sh\ncurl -sLo- http://get.bpkg.sh | bash\nbpkg install rylnd/shpec\n```\n\n### Clone the buildpack\n\nRight now, we are prototyping with a local version of the buildpack. Clone it to your machine.\n\n```sh\ngit clone git@github.com:heroku/nodejs-npm-buildpack.git\n```\n\nClone the Heroku Node.js Engine Cloud Native Buildpack.\n\n```sh\ncd .. # change from nodejs-npm-buildpack directory\ngit clone git@github.com:heroku/nodejs-engine-buildpack.git\n```\n\n### Build the image\n\n#### with buildpacks\n\nUsing pack, you're ready to create an image from the buildpack and source code. You will need to add flags that point to the path of the source code (`--path`) and the paths of the buildpacks (`--buildpack`).\n\n```sh\ncd nodejs-npm-buildpack\npack build TEST_IMAGE_NAME --path ../TEST_REPO_PATH --buildpack ../nodejs-engine-buildpack --buildpack ../nodejs-npm-buildpack\n```\n\n#### with a builder\n\nYou can also create a `builder.toml` file that will have explicit directions when creating a buildpack. This is useful when there are multiple \"detect\" paths a build can take (ie. yarn vs. npm commands).\n\nIn a directory outside of this buildpack, create a builder file:\n\n```sh\ncd ..\nmkdir heroku_nodejs_builder\ntouch heroku_nodejs_builder/builder.toml\n```\n\nFor local development, you'll want the file to look like this:\n\n```toml\n[[buildpacks]]\n  id = \"heroku/nodejs-engine\"\n  uri = \"../nodejs-engine-buildpack\"\n\n[[buildpacks]]\n  id = \"heroku/nodejs-npm\"\n  uri = \"../nodejs-npm-buildpack\"\n\n[[order]]\n  group = [\n    { id = \"heroku/nodejs-engine\", version = \"0.4.3\" },\n    { id = \"heroku/nodejs-npm\", version = \"0.1.4\" }\n  ]\n\n[stack]\n  id = \"heroku-18\"\n  build-image = \"heroku/pack:18\"\n  run-image = \"heroku/pack:18\"\n```\n\nCreate the builder with `pack`:\n\n```sh\npack create-builder nodejs --config ../heroku-nodejs-builder/builder.toml\n```\n\nNow you can use the builder image instead of chaining the buildpacks.\n\n```sh\npack build TEST_IMAGE_NAME --path ../TEST_REPO_PATH --builder nodejs\n```\n\n### Common Issues\n\n#### `jq: Permission denied` on a build\n\nThis issue may happen if a binary that is installed is not executable. This may happen on a Linux machine or while using a private network, such as a VPN, when using a local buildpack tool. If using `sfdx evergreen` or `pack`, pass in `--network host` to the command.\n\nAn example of this command running from the source code directory with a local builder image called `nodejs` would look like this:\n\n```sh\npack build TEST_IMAGE_NAME --builder nodejs --network host\n```\n\nIf building a function with `sfdx`, a command looks like this:\n\n```sh\nsfdx evergreen:functions:build image-repo/myfunction:dev --network host\n```\n\n## Testing\n\nThe complete test suite needs Docker to run. Make sure to [install Docker first](https://hub.docker.com/search?type=edition\u0026offering=community).\n\n```sh\nmake test\n```\n\nIf you want to run individual test suites, that's available too.\n\n**Unit Tests**\n\nTo run the tests on the local host, [make sure `shpec` is installed](#install-shpec-optional).\n\n```sh\nmake unit-test\n```\n\n### Unit tests in Docker\n\nRunning the `shpec` aren't ideal since the test scripts read and write to the local buildpack directory, so Docker may be preferred.\n\nAs suggested above, install [Docker](#testing). Next, run the tests with the Make script:\n\n```sh\nmake docker-unit-test\n```\n\n### Debugging tests\n\nTo debug, make changes from the code and rerun with the make command. To see what is happening, I suggest wrapping code blocks in question with `set -x`/`set +x`. It would look like this in the shpec file:\n\n```sh\nset -x\nit \"creates a toolbox.toml\"\n  install_or_reuse_toolbox \"$layers_dir/toolbox\"\n\n  assert file_present \"$layers_dir/toolbox.toml\"\nend\nset +x\n```\n\n## Contributing\n\n1. Open a pull request.\n2. Make update to `CHANGELOG.md` under `main` with a description (PR title is fine) of the change, the PR number and link to PR.\n3. Let the tests run on CI. When tests pass and PR is approved, the branch is ready to be merged.\n4. Merge branch to `main`.\n\n### Release\n\nNote: if you're not a contributor to this project, a contributor will have to make the release for you.\n\n1. Create a new branch (ie. `1.14.2-release`).\n2. Update the version in the `buildpack.toml`.\n3. Move the changes from `main` to a new header with the version and date (ie. `1.14.2 (2020-02-30)`).\n4. Open a pull request.\n5. Let the tests run on CI. When tests pass and PR is approved, the branch is ready to be merged.\n6. Merge branch to `main`.\n7. Pull down `main` to local machine.\n8. Tag the current `main` with the version. (`git tag v1.14.2`)\n9. Push up to GitHub. (`git push origin main --tags`) CI will run the suite and create a new release on successful run.\n\n## Glossary\n\n- buildpacks: provide framework and a runtime for source code. Read more [here](https://buildpacks.io).\n- OCI image: [OCI (Open Container Initiative)](https://www.opencontainers.org/) is a project to create open sourced standards for OS-level virtualization, most importantly in Linux containers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroku%2Fnodejs-npm-buildpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheroku%2Fnodejs-npm-buildpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroku%2Fnodejs-npm-buildpack/lists"}