Repository navigation
Renovate not using npm version that corresponds to Node version by default #46368
Replies: 4 comments
|
Your expectation is reasonable, and the Something is supplying the observed For an immediate deterministic workaround, set an explicit npm constraint, e.g. References: npm version configuration, v44.104.2 npm post-update source. |
|
I double and triple checked my repos for a hidden npm constraint, and I didn't see anything. Looking at the renovate source code, it seems like renovate will default to npm >=7 for lockFileVersion 3. locked-versions.ts Line 93 else if (lockfileVersion === 3) {
if (!packageFile.extractedConstraints?.npm) {
npm = '>=7';
}
} In the meantime, I set a package.json engine constraint to "npm": "^11". Downside is that renovate immediately tries to update it to "^12" 🤦♂️ |
|
@arichesson's analysis is right. Set the constraint in your {
"constraints": {
"npm": "^11"
}
}
|
|
The constraint set in my renovate config is not a good solution long term because it requires manual upgrades, something renovate is supposed to do for me. Setting it as a package.json engine setting would be fine as long as renovate kept the npm version matched with the node version. I'm finding that node 24 doesn't use the latest version of npm 11 and thus has minor variations in how the lock file is generated. As I said above, we rely on the .node-version file in our repo to set the node and npm version in both cli and on dev's local environment. I'm asking that the .node-version file should drive the renovate npm version by default as well. |
Uh oh!
There was an error while loading. Please reload this page.
How are you running Renovate?
Self-hosted Renovate CLI
Which platform you running Renovate on?
Other (please specify)
Which version of Renovate are you using?
44.104.2
Please tell us more about your question or problem
Based on this issue Default npm to use default version from node, I expect renovate to use the npm version that corresponds to the matching node version defined in my project using a .nvmrc or .node-version file. I'm running renovate using the docker container to allow it to install npm versions using the
binarySource:installoption. I have not constrained the npm version using a constraint or engine file as is documented here. According to that github issue, it seems like the intent was that if no constraints are specified, renovate should choose to use the npm version that was shipped with the node version. This makes it consistent with how most node version managers work for local development.See the following logs.
My package-lock file has
"lockfileVersion": 3, I have a .node-version file with24.21.0as the contents. I have no engine or renovate npm constraints.Renovate picked up version 24.21.0 from my node version. It installed node 24.21.0 AND npm 11.19.0, but then installed npm version 12.0.2 and used that version instead.
Summary
When no engine or constraints option is specified
AND I have specified a node constraint using a .node-version or .nvmrc file (node@24.21.0)
Expected:
renovate uses/installs the matching npm version that was shipped my node version (npm@11.19.0)
Actual:
renovate uses generic fallback constraint that resolves to latest npm version (npm@12.0.2)
Logs (if relevant)
Logs
All reactions