Package resolution based on Node.js version #445
-
Recently I wanted to upgrade mocha to v9, which drops support for Node.js 10.x. However, our project (a library) still has users on 10.x, so we still run CI on 10.x. There weren't any major API changes, so I changed the mocha constraint in package.json to However, on pushing to CI, I noticed moha v9 was getting installed, even on Node.js 10.x, despite the fact that mocha v9 sets its Could npm rather try a lower version, if the highest available one fails an engine requirement? Is there already a way to achieve this? Composer (PHP) does this, and it makes it easy to support multiple versions of a package per environment. I imagine it would be a nontrivial change to npm's resolution logic, but surely it's doable? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Have you tried with npm 7 latest? I'm relatively sure it takes engines into account already. |
Beta Was this translation helpful? Give feedback.
-
@shalvah we will not likely change behavior on npm 6, but we could try and improve this for 7 Please open an issue over at https://github.com/npm/rfcs if you think this should be categorized as a new feature or an issue at https://github.com/npm/cli if you believe this qualifies more as a bug /cc @npm/cli for visibility |
Beta Was this translation helpful? Give feedback.
@shalvah we will not likely change behavior on npm 6, but we could try and improve this for 7
Please open an issue over at https://github.com/npm/rfcs if you think this should be categorized as a new feature or an issue at https://github.com/npm/cli if you believe this qualifies more as a bug
/cc @npm/cli for visibility