Error resolving dependency tree when updating Sanity project's dependencies.
13 replies
Last updated: Apr 24, 2024
F
I am attempting to update a simple Sanity project to the latest dependencies. Here is my current package.json . Per documentation , I am doing
I don't care about
npm install sanity@latestand getting the immediate failure:
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: loumarc@1.0.0 npm ERR! Found: styled-components@5.3.11 npm ERR! node_modules/styled-components npm ERR! styled-components@"^5.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer styled-components@"^6.1" from sanity@3.38.0 npm ERR! node_modules/sanity npm ERR! sanity@"3.38.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
styled-components. I don't use
styled-components. I assume the only reason this is in my
package.jsonis because Sanity needs it. I tried removing it from my deps, and still get this error. I am at a loss. What is this error trying to tell me? How do I fix it?
Apr 21, 2024, 11:23 AM
F
I am using node v20.12.2 and npm 10.5.0
Apr 21, 2024, 11:25 AM
F
... and if the answer is to use
--legacy-peer-depswell isn't that a temporary solution? Isn't the best practice to keep your dependencies up to date? Feels like
--legacy-peer-depsis asking for potential future issues.
Apr 21, 2024, 11:34 AM
A
1. update the styled components
Apr 21, 2024, 1:40 PM
A
2. if 1 is not working uninstall the package "npm uninstall styled-components" and remove "node modules" and "package-lock.json" and run "npm i"
Apr 21, 2024, 1:41 PM
F
Did 1, got the same error.
Apr 21, 2024, 2:20 PM
F
Did 2 because that's the equivalent of "did you turn it off and back on" for Node/npm 🤣
Apr 21, 2024, 2:21 PM
F
🤷‍♂️
Apr 21, 2024, 2:21 PM
R
Edit your package.json file, and change the line with styled-components so it looks like this
Now you have allowed it to update past major version 5, and things should work!
Sometimes it helps to run
"styled-components": "^6.1.8",
Sometimes it helps to run
npm outdatedto get a list of everything that has an update available.
Apr 22, 2024, 11:59 AM
F
Thanks
user E
. I think y'all are starting to see my frustration. These are all great ideas. I have done all of these, and I still get this error when running npm install sanity@latest
npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @sanity/vision@3.14.4 npm ERR! Found: styled-components@6.1.8 npm ERR! node_modules/styled-components npm ERR! peer styled-components@"^5.2 || ^6" from @sanity/ui@1.9.3 npm ERR! node_modules/@sanity/ui npm ERR! @sanity/ui@"^1.7.2" from @sanity/vision@3.14.4 npm ERR! node_modules/@sanity/vision npm ERR! @sanity/vision@"^3.14.4" from the root project npm ERR! @sanity/ui@"^1.7.4" from the root project npm ERR! styled-components@"^6.1.8" from the root project npm ERR! 1 more (sanity) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer styled-components@"^5.2" from @sanity/vision@3.14.4 npm ERR! node_modules/@sanity/vision npm ERR! @sanity/vision@"^3.14.4" from the root project npm ERR! npm ERR! Conflicting peer dependency: styled-components@5.3.11 npm ERR! node_modules/styled-components npm ERR! peer styled-components@"^5.2" from @sanity/vision@3.14.4 npm ERR! node_modules/@sanity/vision npm ERR! @sanity/vision@"^3.14.4" from the root project
Apr 22, 2024, 1:12 PM
F
I went back through the advice here and realized I missed a KEY point
user U
made. Remove the package-lock.json. After I did that
npm install sanity@latestworked.
Apr 22, 2024, 1:15 PM
A
yes it will work i got the same error day before yesterday i am solving it for 6 days after that i read lots of documentations and discussions and finally found it
Apr 22, 2024, 5:47 PM
F
I guess this is a skill issue on my part. I have to know to remove
package-lock.jsonwhen upgrading
npmpackages?
Apr 24, 2024, 12:06 PM
R
It is frowned upon, but I sometimes resort to it as well. It shouldn’t be necessary.
Apr 24, 2024, 2:00 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.