-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
bug: overrides property only honored when running install the first time #5850
Comments
I can confirm that I have the same issue on the latest This is really disruptive for our CI. Anyone working with a committed package-lock.json isn't running the overrides for the first time. So in a sense, it's not functional for them. I think this bug should be prioritized. |
I too think this bug should be a priority. |
This reproduced for me on {
"name": "test",
"version": "1.0.0",
"dependencies": {
"json-server": "0.17.0"
},
"overrides": {
"package-json": "7.0.0"
}
} |
Hi, this problem is still present in npm I have created a more thorough repro case. Initial state "node_modules/cssom": {
"version": "0.3.8",
},
"node_modules/cssstyle": {
"version": "2.2.0",
"dependencies": {
"cssom": "~0.3.6"
},
} After adding an override and running the After changing the version of the "node_modules/cssom": {
"version": "0.3.8",
},
"packages/package1/node_modules/cssstyle": {
"version": "2.3.0",
"dependencies": {
"cssom": "~0.3.6"
},
} Now the override is still not honored and on top of that the The only workaround we found to work is to uninstall and then install that package again when touching the override or the package's version. Which is really really cumbersome in large monorepos. Running "node_modules/cssom": {
"version": "0.3.6",
},
"node_modules/cssstyle": {
"version": "2.3.0",
"dependencies": {
"cssom": "~0.3.6"
},
} I hope this helps to move this issue further. Feel free to ask for additional info. |
Also, I'd like to pile on that as this issue can cause packages to silently revert to vulnerable versions, IMHO this is not a regular bug, but a security issue, that should also be fixed on the latest version 8. |
The override property runs fine in my local machine but somehow doesn't read in the CI pipeline and gives the security vulnerabilities leading to a pipeline failure. Any suggestions on this? |
Did you try my repro case? I think it is still the same problem. |
I was looking to override the version of semver package which is on the outer layer . Do you recommend adding the npm uninstall semver and then npm install semver to the docker file which is used in the CI pipeline? |
Also running into this issue! Additionally it's not quite clear to me when overrides are applied and when not, and how it affects upstream packages, etc. |
Just want to pop back in and say I tried using an override again recently, including with wiping |
I am facing the same issue on npm v9.8.1 as well. Using |
Is this being worked on? If not, can we please at least get an estimate when this will be fixed? This really is critical bug and makes npm almost unusable. |
You should switch to yarn or pnpm if it becomes critical. Both yarn and pnpm will update the lockfile after seeing modified You really should not expect npm to fix this issue. The npm team, having realized the issue (this issue was opened by one of them) a year ago, has yet to take any action on fixing this. They never share their ideas and updates about this issue. If you have no choice but to stick with npm, viable workarounds do exist. You can simply run |
I opened a pull request that starts to fix the issue. |
I am encountering this on 10.2.5. My workaround was to go delete the entry for the offending package from package-lock.json by hand before running npm install. Anyone know of a good tool to automate removing all references to a specific package from package-lock.json? |
For this override: "overrides": {
"ng2-charts@^5.0.4": {
"@angular/cdk@>=16.0.0": "^16.0.0"
} I just write a sed like:
|
@rgant Nice, that will cover a lot of cases. I was thinking maybe a node script that reads package-lock.json in as an object, loops through finds any package definitions (resolutions?) that end with the target package name, deletes them from the object, and then writes back to package-lock.json e.g. (not a real command for those of you who are just skimming for a solution)
would edit package-lock.json to delete the object that has the key Overkill for me to write that now that I've already solved it manually. 😆 |
I found a little tediuos but working workaround (after adding overrides):
then in the ouput note the module prefixed by take all those packages and uninstall them, then install with the same versions again, eg:
|
@OZZlE that worked wonderfully! Much better than the advice to run |
I had the same issue. Using @OZZlE's solution is the only thing that worked for me. Affected versions:
|
With packages that add overrides as a service this is not the best. I'm looking for a scripted way to avoid this. At the moment that's calling |
I wouldn't recommend using In fact, I wouldn't recommend using npm at all, just use pnpm/yarn. |
Opening a new issue since #4232 is getting crowded with other possibly unreleated bug reports. But this one I have confirmed.
From: #4232 (comment)
I can confirm this is the behavior in the latest
npm@8.19.2
. This can be reproduced easily with the followingpackage.json
:npm install
in the folder containing only the abovepackage.json
--> 0 vulnerabilitiesnpm install
right after the previous (sonode_modules
andpackage-lock.json
exists) --> 5 vulnerabilitiesnpm update
--> 0 vulnerabilitiesrm -rf node_modules/ && npm install
--> 5 vulnerabilitiesrm package-lock.json && npm install
--> 5 vulnerabilitiesrm -rf node_modules/ && rm package-lock.json && npm install
--> 0 vulnerabilitiesFrom the above it can be concluded that the
overrides
property is only honored when runningnpm install
first time (i.e. withoutpackage-lock.json
andnode_modules
present) and when runningnpm update
.The text was updated successfully, but these errors were encountered: