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

np v8 breaking bug: NPM version check fails when npm is not specified in engines field in package.json #696

Closed
JaneJeon opened this issue May 27, 2023 · 2 comments

Comments

@JaneJeon
Copy link

Description

According to npm docs, it's okay to put engines.node but NOT engines.npm: https://docs.npmjs.com/cli/v9/configuring-npm/package-json?v=true#engines

However, np assumes that engines.npm IS specified, and so when you don't have engines.npm specified, it crashes with the message: "Please upgrade to npmundefined" (yes, that is verbatim)!

Steps to reproduce

Literally just run np in a repository with engines.node specified but not engines.npm specified in package.json

Expected behavior

For np to not throw when engines.npm is not specified.

From a quick glance, it looks like the issue is with this part:

const depRange = pkg.engines[dependency];
(where basicall you can't assume that the depRange is present).

Environment

np -8.0.0
Node.js - v18.16.0
npm - v9.5.1

@JaneJeon
Copy link
Author

I can confirm that this error doesn't happen with np@7, meaning the issue is 100% from this PR: #683

So that should help narrow things down!

@JaneJeon JaneJeon changed the title NPM version check fails when npm is not specified in engines field in package.json np v8 breaking bug: NPM version check fails when npm is not specified in engines field in package.json May 27, 2023
@JaneJeon
Copy link
Author

I'll check the fix later, but thanks for the quick response :)

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

No branches or pull requests

1 participant