heroku / heroku/buildpacks-nodejs

Incorrect usage of `npm ci` in `pnpm` scenarios.

Open
#744 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
28
Forks
17
Avg merge
1d 16h
Merged PRs (30d)
14

Description

For builds that have a `pnpm-lock.yaml` (and no other lockfiles), but don't have a `packageManager` field in `package.json`, the current `heroku/nodejs` buildpack attempts to install dependencies with `npm ci`. Not only is this using the wrong package manager, it's also attempting to fetch dependencies without a lockfile.

Potentially, there are a few ways to fix this:

- Introduce a `heroku/pnpm-engine` buildpack that could install `pnpm` in the same manner as our `heroku/npm-engine` buildpack. That would allow us to provide a `pnpm` installation using `engines.pnpm` from `package.json`, or perhaps provide a default `pnpm`.
- Add a check into the `heroku/npm-install` buildpack to throw an error message if there is lockfile from another package manager (like `pnpm-lock.yaml`). Something like "Detected pnpm-lock.yaml. If you wish to use `pnpm`, add `packageManager: "pnpm@8.11.0"` to your package.json".
- Add a check into the `heroku/npm-install` buildpack to throw an error message if there isn't a `package-lock.json`. Something like "We detected npm, but found no package-lock.json. Please run `npm i`, commit the `package-lock.json`, and try again".

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.