Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messaging when installing an incompatible npm version #1134

Merged
merged 6 commits into from
Sep 19, 2023

Conversation

joshwlewis
Copy link
Member

@joshwlewis joshwlewis commented Sep 6, 2023

When installing npm@10 with node@16, users are seeing error messages like this: Unable to install npm >=9; does it exist?.

The issue here is that npm@10 has minimum requirements for the Node.js version it works with: https://github.com/npm/cli/blob/3f9aa452061cde22de1babb33fd9bed8f2b6e3a5/package.json#L257

The npm command emits an error message explaining the issue that looks like this:

npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@10.0.0
npm ERR! notsup Not compatible with your version of node/npm: npm@10.0.0
npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}
npm ERR! notsup Actual:   {"npm":"8.5.0","node":"v16.14.0"}

However, due to the use of shell redirection in the buildpack, the error message never makes it to the user.

This PR drops the stderr redirection so that the underlying error message does appear. In order prevent other needless output on stderr, --no-progress and --no-audit have been added to the install command.

I've also added another hint to the final error message about compatibility.

Related:
KB article explaining the situation and a solution
GUS Work Item

@joshwlewis joshwlewis marked this pull request as ready for review September 6, 2023 20:45
@joshwlewis joshwlewis requested a review from a team as a code owner September 6, 2023 20:45
@edmorley
Copy link
Member

@joshwlewis Is this ready to merge?

@joshwlewis joshwlewis enabled auto-merge (squash) September 19, 2023 14:19
@joshwlewis joshwlewis merged commit bdc2a4d into main Sep 19, 2023
6 checks passed
@joshwlewis joshwlewis deleted the npm-10-engines branch September 19, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants