Reactjs 如何解决gatsby js中的依赖错误?

Reactjs 如何解决gatsby js中的依赖错误?,reactjs,gatsby,Reactjs,Gatsby,我在学习盖茨比的教程。()链接这里 我在window terminal中键入了命令 gatsby new tutorial-part-four https://github.com/gatsbyjs/gatsby-starter-hello-world cd tutorial-part-four npm install gatsby-plugin-typography typography react-typography typography-theme-kirkham gatsby-plu

我在学习盖茨比的教程。()链接这里

我在window terminal中键入了命令

gatsby new tutorial-part-four https://github.com/gatsbyjs/gatsby-starter-hello-world
cd tutorial-part-four

npm install gatsby-plugin-typography typography react-typography typography-theme-kirkham gatsby-plugin-emotion @emotion/react
但是这些消息出现了错误

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: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!   peer react@"^16.9.0 || ^17.0.0" from gatsby-plugin-typography@3.0.0
npm ERR!   node_modules/gatsby-plugin-typography
npm ERR!     gatsby-plugin-typography@"*" from the root project
npm ERR!   2 more (gatsby, react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from react-typography@0.16.19
npm ERR! node_modules/react-typography
npm ERR!   peer react-typography@"^0.16.1 || ^1.0.0-alpha.0" from gatsby-plugin-typography@3.0.0
npm ERR!   node_modules/gatsby-plugin-typography
npm ERR!     gatsby-plugin-typography@"*" 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 C:\Users\pc\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\pc\AppData\Local\npm-cache\_logs\2021-03-13T09_43_09_116Z-debug.log

我想知道如何解决这些错误?

我认为错误来自
npm
版本

尝试在npm安装命令中添加
--legacy peer deps
选项

npm install gatsby-plugin-typography typography react-typography typography-theme-kirkham gatsby-plugin-emotion @emotion/react --legacy-peer-deps 
或者在清理npm后使用以下命令进行尝试

npm cache clean --force

react排版术
尚未准备好react 17,因此您必须将react降级到版本16才能使用它

编辑
package.json
并查找:

"dependencies": {
  ...
  "react": "^17.0.1",
  "react-dom": "^17.0.1",
  ...
},
将版本号更改为
16.14.0

"dependencies": {
  ...
  "react": "^16.14.0",
  "react-dom": "^16.14.0",
  ...
},
保存它,然后从
node\u modules/

rm-Rf节点模块

最后,只需使用以下命令重新安装所有内容:

npm安装

继续你的命令

npm安装盖茨比插件排版排版反应排版主题kirkham gatsby插件情绪@emotion/react