我正试图解决盖茨比项目中的一个错误。
当我在CLI中运行npm更新时,我得到了以下错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! node_modules/react
npm ERR! react@"^18.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.2" from simple-react-lightbox@3.6.9-0
npm ERR! node_modules/simple-react-lightbox
npm ERR! simple-react-lightbox@"^3.6.9-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.当我通过CLI构建网站(gatsby build)时,它可以工作,但是当我将它部署到Netlify时,我会得到相同的错误:
4:05:39 PM: npm ERR! code ERESOLVE
4:05:39 PM: npm ERR! ERESOLVE could not resolve
4:05:39 PM: npm ERR!
4:05:39 PM: npm ERR! While resolving: simple-react-lightbox@3.6.9-0
4:05:39 PM: Creating deploy upload records
4:05:39 PM: npm ERR! Found: react@18.1.0
4:05:39 PM: npm ERR! node_modules/react
4:05:39 PM: npm ERR! react@"^18.1.0" from the root project
4:05:39 PM: npm ERR! peer react@">=16.8 || ^17.0.0" from framer-motion@4.1.17
4:05:39 PM: npm ERR! node_modules/framer-motion
4:05:39 PM: npm ERR! framer-motion@"^4.1.17" from simple-react-lightbox@3.6.9-0
4:05:39 PM: npm ERR! node_modules/simple-react-lightbox
4:05:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
4:05:39 PM: npm ERR! simple-react-lightbox@"^3.6.9-0" from the root project
4:05:39 PM: npm ERR! 15 more (nano-css, react-dom, react-helmet, react-masonry-css, ...)
4:05:39 PM: npm ERR!
4:05:39 PM: npm ERR! Could not resolve dependency:
4:05:39 PM: npm ERR! peer react@"^17.0.2" from simple-react-lightbox@3.6.9-0
4:05:39 PM: npm ERR! node_modules/simple-react-lightbox
4:05:39 PM: npm ERR! simple-react-lightbox@"^3.6.9-0" from the root project
4:05:39 PM: npm ERR!
4:05:39 PM: npm ERR! Conflicting peer dependency: react@17.0.2
4:05:39 PM: npm ERR! node_modules/react
4:05:39 PM: npm ERR! peer react@"^17.0.2" from simple-react-lightbox@3.6.9-0
4:05:39 PM: npm ERR! node_modules/simple-react-lightbox
4:05:39 PM: npm ERR! simple-react-lightbox@"^3.6.9-0" from the root project
4:05:39 PM: npm ERR!
4:05:39 PM: npm ERR! Fix the upstream dependency conflict, or retry
4:05:39 PM: npm ERR! this command with --force, or --legacy-peer-deps
4:05:39 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.对如何解决这个问题有什么想法吗?
发布于 2022-06-03 08:41:39
我看到这个方案已经被否决了。它从很短的时间前就不再被支持了。我已经把反应从17降到18。这似乎很有效。
https://www.npmjs.com/package/simple-react-lightbox
My steps:
(npm install --save react@17.0.2 react-dom@17.0.2)
gatsby clean
npm install发布于 2022-06-03 03:24:59
几分钟前,我遇到了类似的问题,但是我能够通过使用--force标志强制安装它来解决这个问题,所以您可以通过以下方式安装它:
npm install --force simple-react-lightbox我认为问题是,您想要安装的依赖/包是构建在Reactiv17.x上的,并且您正在使用Reactiv18.x上的一个项目
我希望这能解决你的问题。
https://stackoverflow.com/questions/72478068
复制相似问题