如何更新我的 gatsby 及其依赖项
Posted
技术标签:
【中文标题】如何更新我的 gatsby 及其依赖项【英文标题】:How to update my gatsby and its dependences 【发布时间】:2021-06-01 12:48:22 【问题描述】:我是 React 的新手,我正在尝试更新我的 gatsby 及其依赖项,但无法正常工作。
在终端上我输入了npm outdated
,我在下面得到了这个。
Package Current Wanted Latest Location Depended by
gatsby 2.32.4 2.32.9 3.0.0 node_modules/gatsby form-gatsby
gatsby-plugin-sass 3.2.0 3.2.0 4.0.0 node_modules/gatsby-plugin-sass form-gatsby
gatsby-source-filesystem 2.11.1 2.11.1 3.0.0 node_modules/gatsby-source-filesystem form-gatsby
gatsby-transformer-remark 2.16.1 2.16.1 3.0.0 node_modules/gatsby-transformer-remark form-gatsby
react 16.13.1 16.14.0 17.0.1 node_modules/react form-gatsby
react-dom 16.13.1 16.14.0 17.0.1 node_modules/react-dom form-gatsby
当我尝试运行此程序时:npm update
我在下面收到此错误。
npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: graphql@15.5.0
npm WARN node_modules/graphql
npm WARN graphql@"^15.4.0" from gatsby@3.0.0
npm WARN node_modules/gatsby
npm WARN gatsby@"3.0.0" from the root project
npm WARN 6 more (gatsby-plugin-image, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer graphql@"^14.4.1" from express-graphql@0.9.0
npm WARN node_modules/express-graphql
npm WARN express-graphql@"^0.9.0" from gatsby@3.0.0
npm WARN node_modules/gatsby
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: gatsby@3.0.0
npm ERR! node_modules/gatsby
npm ERR! gatsby@"3.0.0" from the root project
npm ERR! peer gatsby@"^3.0.0-next.0" from gatsby-plugin-image@1.0.0
npm ERR! node_modules/gatsby-plugin-image
npm ERR! gatsby-plugin-image@"^1.0.0" from gatsby-source-contentful@5.0.0
npm ERR! node_modules/gatsby-source-contentful
npm ERR! gatsby-source-contentful@"^5.0.0" from the root project
npm ERR! 5 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer gatsby@"^2.0.0" from gatsby-plugin-sass@3.2.0
npm ERR! node_modules/gatsby-plugin-sass
user@Users-MacBook-Pro form-gatsby % npm update
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gatsby-starter-hello-world@0.1.0
npm ERR! Found: gatsby@2.32.9
npm ERR! node_modules/gatsby
npm ERR! gatsby@"^2.26.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer gatsby@"^3.0.0-next.0" from gatsby-plugin-sharp@3.0.0
npm ERR! node_modules/gatsby-plugin-sharp
npm ERR! gatsby-plugin-sharp@"^3.0.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.
npm ERR!
npm ERR! See /Users/user/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2021-03-02T23_15_17_390Z-debug.log
我尝试运行npm install --force gatsby@3.0.0
,但同样没有用。
你们有什么办法可以更新这个吗?
非常感谢。
【问题讨论】:
【参考方案1】:这意味着您尝试更新的版本已找到
npm ERR! gatsby@"3.0.0" from the root project
运行 gatsby -v 查看版本是否是最新的
【讨论】:
【参考方案2】:尝试运行npm install gatsby@latest
只有在那之后运行npm outdated
【讨论】:
非常感谢!实际上,当我做npm install gatsby@latest --legacy--peer-deps
时,jsut 起作用了以上是关于如何更新我的 gatsby 及其依赖项的主要内容,如果未能解决你的问题,请参考以下文章
我的 Gatsby GraphQL 架构不会使用新的 Sanity 架构进行更新