heroku / heroku/buildpacks-nodejs
Improper engines.npm field causes error in `Checking Node.js version`
- Dominant language
- Rust
- Stars
- 28
- Forks
- 17
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 14
Description
When the `package.json` has invalid content for fields in the engine, the `Checking Node.js version`step of the buildpack throws an error that says `Could not parse package.json. No valid ranges could be parsed at line ... column ...`. However, when using `yarn` locally, the installation is successful without any warnings or errors. This could lead to confusion when developers have the same repo config working locally but not on Heroku.
## Reproducing Steps
run `pack build` using heroku-24 builder on a `package.json` [(e.g. this one in Discourse)](https://github.com/discourse/discourse/blob/7f0e6e95928119e31591c5c39361b2851924d48d/package.json#L82) that has "please-use-yarn" as the content for the field engines.npm.
## Expected outcome
The buildpack should either warn the user that there is invalid content more explicitly right before or after the error, provide suggestions for what could possibly be the problem, or ignore the problem and proceed with using `yarn` (akin to local `yarn` behavior).
## Actual result
```
===> ANALYZING
Restoring data for SBOM from previous image
===> DETECTING
3 of 5 buildpacks participating
heroku/nodejs-engine 3.2.7
heroku/nodejs-yarn 3.2.7
heroku/ruby 3.0.0
===> RESTORING
===> BUILDING
[Heroku Node.js Engine Buildpack]
[Checking Node.js version]
[Error: Node.js engine package.json error]
Couldn't parse package.json: Could not parse package.json. No valid ranges could be parsed at line 82 column 29
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
```
Contributor guide
Research direction
Start by reproducing the failure with pack build using the heroku-24 builder and the Discourse package.json example, focusing on the Checking Node.js version step. Investigate how invalid engines.npm content is handled and determine whether the finished behavior should provide a clearer warning or continue with yarn, then verify the build outcome and error messaging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100