mapbox / node-pre-gyp

Node.js tool for easy binary deployment of C++ addons
BSD 3-Clause "New" or "Revised" License
1.12k stars 263 forks source link

Downgrade npmlog + upgrade gauge to address #623 #624

Closed springmeyer closed 2 years ago

springmeyer commented 2 years ago

This should address #623

TODO:

wraithgar commented 2 years ago

Why were, before this PR, tests not failing on node v10

I can answer this and save you some time: because this was a pre-emptive drop in support. Nothing in the code was changed that would have broke in node10.

The only thing that would catch something like this would be the --engine-strict flag.

springmeyer commented 2 years ago

Ah! Thank you for explaining that. I saw the --engine-strict mention in #623, but did not connect the dots on how it was the sole thing that caught this. Thanks.

springmeyer commented 2 years ago

Hmm, @wraithgar - I just tried, locally, running

npm install --production --engine-strict

against the master branch (without this PRs fix) and it works without errors:

added 54 packages from 21 contributors and audited 394 packages in 1.684s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

$ npm ls gauge                            
@mapbox/node-pre-gyp@1.0.7 /Users/danespringmeyer/projects/node-pre-gyp
└─┬ npmlog@6.0.0
  └── gauge@4.0.0 

Any idea why that is not erroring? I would assume I'd get a non-zero return code from npm install or npm ci with --engine-strict

springmeyer commented 2 years ago

Perhaps I need to add engines to the package.json of node-pre-gyp?

wraithgar commented 2 years ago

It looks like npm@6 is not checking engines when installing from a package-lock. npm@7 always checks.

bcoe commented 2 years ago

:tada: thanks for taking on this work. I know I'm like the only person who runs tests with --engine-strict :laughing:, and that I can be a squeaky wheel.

Edit: my experience has been, this is good to treat as a breaking change, or you eventually get burned by someone upstream using a new feature, e.g., ESM in the case of having a dep move to Node 12.

springmeyer commented 2 years ago

@bcoe - no problem, I'd like to be like you. I'm still struggling however to replicate any kind of error or failure with node v10 (or 8 for that matter) and the master code before this fix. Even with npm@7. Would you be up for providing a PR to this repo's .travis.yml that demonstrates how to detect with --engine-strict the problem you were able to catch with CI? So, a PR that fails and then would pass once this PR is merged in.

bcoe commented 2 years ago

@springmeyer this is the approach I've been taking that catches things:

https://github.com/googleapis/nodejs-logging/blob/main/.github/workflows/ci.yaml#L22

bcoe commented 2 years ago

@springmeyer I did some local testing too, and a couple things I noticed:

Once I did both these things, I'm getting the following with a local check out of node-pre-gyp:

node-pre-gyp$ npm i -production --engine-strict
npm ERR! code ENOTSUP
npm ERR! notsup Unsupported engine for npmlog@6.0.0: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"10.24.1","npm":"6.14.15"})
npm ERR! notsup Not compatible with your version of node/npm: npmlog@6.0.0
npm ERR! notsup Not compatible with your version of node/npm: npmlog@6.0.0
npm ERR! notsup Required: {"node":"^12.13.0 || ^14.15.0 || >=16"}
npm ERR! notsup Actual:   {"npm":"6.14.15","node":"10.24.1"}
springmeyer commented 2 years ago

Got it, thank you @bcoe - npm@7 + using node v10 allowed me to replicate (and it caught another incompatible dependency - action-walk).

springmeyer commented 2 years ago

This is now published as @mapbox/node-pre-gyp@1.0.8

minherz commented 2 years ago

Thanks for this work 👏 it allows us to avoid dropping Node 10 on @google-cloud/profiler