在 gatsby 中安装包时出现弃用错误

deprecated errors while installing packagesin gastby

我正在使用 Gatsby 主题并在安装包时遇到此错误, 我试过了 npm install --legacy-peer-deps 但是当我 运行 gatsby develop 我再次得到错误: 这是我面临的错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-owl-carousel3@2.2.5
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@"15.x || 16.x || 17.x" from @gatsbyjs/reach-router@1.3.6
npm ERR!   node_modules/@gatsbyjs/reach-router
npm ERR!     @gatsbyjs/reach-router@"^1.3.6" from gatsby@4.6.0
npm ERR!     node_modules/gatsby
npm ERR!       gatsby@"^4.4.0" from the root project
npm ERR!       12 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     peer @gatsbyjs/reach-router@"^1.3.5" from gatsby-link@4.6.0
npm ERR!     node_modules/gatsby-link
npm ERR!       gatsby-link@"^4.6.0" from gatsby@4.6.0
npm ERR!       node_modules/gatsby
npm ERR!         gatsby@"^4.4.0" from the root project
npm ERR!         12 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     1 more (gatsby-react-router-scroll)
npm ERR!   18 more (@loadable/component, gatsby, gatsby-link, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from react-owl-carousel3@2.2.5
npm ERR! node_modules/react-owl-carousel3
npm ERR!   react-owl-carousel3@"^2.2.5" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@16.14.0
npm ERR! node_modules/react
npm ERR!   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from react-owl-carousel3@2.2.5
npm ERR!   node_modules/react-owl-carousel3
npm ERR!     react-owl-carousel3@"^2.2.5" from the root project
npm ERR!
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\foxxp\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\foxxp\AppData\Local\npm-cache\_logs22-05-04T23_14_25_607Z-debug-0.log

似乎有很多弃用的版本 请问我该如何解决这个问题??

尝试:

  • 删除你的node_modules
  • 再次安装(对等)依赖项:
    npm install --legacy-peer-deps
    
  • 再次开始开发过程:
    gatsby develop
    

如果问题仍然存在,请删除您的 package-lock.json 文件并重做上述所有过程。