首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我试图部署我的Gatsby网站时,为什么会收到错误消息?

当我试图部署我的Gatsby网站时,为什么会收到错误消息?
EN

Stack Overflow用户
提问于 2022-06-25 18:28:51
回答 1查看 314关注 0票数 0

我有盖茨比的应用程序。

当我在本地构建它时,它工作得很好,但是当我尝试将它部署到Netlify或Gitlab时,我会得到以下错误消息: Netlify错误消息:

代码语言:javascript
复制
8:44:20 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:44:20 PM: npm WARN config location in the cache, and they are managed by
8:44:20 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:44:20 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:44:20 PM: npm WARN config location in the cache, and they are managed by
8:44:20 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:44:23 PM: npm ERR! code ERESOLVE
8:44:23 PM: npm ERR! ERESOLVE could not resolve
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! While resolving: @mdx-js/react@1.6.22
8:44:23 PM: Creating deploy upload records
8:44:23 PM: npm ERR! Found: react@18.1.0
8:44:23 PM: npm ERR! node_modules/react
8:44:23 PM: npm ERR!   react@"^18.1.0" from the root project
8:44:23 PM: npm ERR!   peer react@"15.x || 16.x || 17.x || 18.x" from @gatsbyjs/reach-router@1.3.7
8:44:23 PM: npm ERR!   node_modules/@gatsbyjs/reach-router
8:44:23 PM: npm ERR!     @gatsbyjs/reach-router@"^1.3.6" from gatsby@4.17.1
8:44:23 PM: npm ERR!     node_modules/gatsby
8:44:23 PM: npm ERR!       gatsby@"^4.17.1" from the root project
8:44:24 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
8:44:23 PM: npm ERR!       13 more (babel-plugin-remove-graphql-queries, ...)
8:44:23 PM: npm ERR!     peer @gatsbyjs/reach-router@"^1.3.5" from gatsby-link@4.17.0
8:44:23 PM: npm ERR!     node_modules/gatsby-link
8:44:23 PM: npm ERR!       gatsby-link@"^4.17.0" from gatsby@4.17.1
8:44:23 PM: npm ERR!       node_modules/gatsby
8:44:23 PM: npm ERR!         gatsby@"^4.17.1" from the root project
8:44:23 PM: npm ERR!         13 more (babel-plugin-remove-graphql-queries, ...)
8:44:23 PM: npm ERR!     1 more (gatsby-react-router-scroll)
8:44:23 PM: npm ERR!   9 more (gatsby, gatsby-link, gatsby-plugin-image, ...)
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Could not resolve dependency:
8:44:23 PM: npm ERR! peer react@"^16.13.1 || ^17.0.0" from @mdx-js/react@1.6.22
8:44:23 PM: npm ERR! node_modules/@mdx-js/react
8:44:23 PM: npm ERR!   @mdx-js/react@"^1.6.22" from the root project
8:44:23 PM: npm ERR!   peer @mdx-js/react@"^1.0.0" from gatsby-plugin-mdx@3.17.0
8:44:23 PM: npm ERR!   node_modules/gatsby-plugin-mdx
8:44:23 PM: npm ERR!     gatsby-plugin-mdx@"^3.17.0" from the root project
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Conflicting peer dependency: react@17.0.2
8:44:23 PM: npm ERR! node_modules/react
8:44:23 PM: npm ERR!   peer react@"^16.13.1 || ^17.0.0" from @mdx-js/react@1.6.22
8:44:23 PM: npm ERR!   node_modules/@mdx-js/react
8:44:23 PM: npm ERR!     @mdx-js/react@"^1.6.22" from the root project
8:44:23 PM: npm ERR!     peer @mdx-js/react@"^1.0.0" from gatsby-plugin-mdx@3.17.0
8:44:23 PM: npm ERR!     node_modules/gatsby-plugin-mdx
8:44:23 PM: npm ERR!       gatsby-plugin-mdx@"^3.17.0" from the root project
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Fix the upstream dependency conflict, or retry
8:44:23 PM: npm ERR! this command with --force, or --legacy-peer-deps
8:44:23 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
8:44:23 PM: npm ERR! A complete log of this run can be found in:
8:44:23 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-25T17_44_20_693Z-debug-0.log
8:44:23 PM: Error during NPM install
8:44:23 PM: Build was terminated: Build script returned non-zero exit code: 1
8:44:23 PM: Failing build: Failed to build site
8:44:24 PM: Finished processing build request in 11.866525747s

Gitlab错误信息:

代码语言:javascript
复制
$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @mdx-js/react@1.6.22
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"^18.1.0" from the root project
npm ERR!   peer react@"15.x || 16.x || 17.x || 18.x" from @gatsbyjs/reach-router@1.3.7
npm ERR!   node_modules/@gatsbyjs/reach-router
npm ERR!     @gatsbyjs/reach-router@"^1.3.6" from gatsby@4.17.1
npm ERR!     node_modules/gatsby
npm ERR!       gatsby@"^4.17.1" from the root project
npm ERR!       13 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     peer @gatsbyjs/reach-router@"^1.3.5" from gatsby-link@4.17.0
npm ERR!     node_modules/gatsby-link
npm ERR!       gatsby-link@"^4.17.0" from gatsby@4.17.1
npm ERR!       node_modules/gatsby
npm ERR!         gatsby@"^4.17.1" from the root project
npm ERR!         13 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     1 more (gatsby-react-router-scroll)
npm ERR!   9 more (gatsby, gatsby-link, gatsby-plugin-image, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1 || ^17.0.0" from @mdx-js/react@1.6.22
npm ERR! node_modules/@mdx-js/react
npm ERR!   @mdx-js/react@"^1.6.22" from the root project
npm ERR!   peer @mdx-js/react@"^1.0.0" from gatsby-plugin-mdx@3.17.0
npm ERR!   node_modules/gatsby-plugin-mdx
npm ERR!     gatsby-plugin-mdx@"^3.17.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^16.13.1 || ^17.0.0" from @mdx-js/react@1.6.22
npm ERR!   node_modules/@mdx-js/react
npm ERR!     @mdx-js/react@"^1.6.22" from the root project
npm ERR!     peer @mdx-js/react@"^1.0.0" from gatsby-plugin-mdx@3.17.0
npm ERR!     node_modules/gatsby-plugin-mdx
npm ERR!       gatsby-plugin-mdx@"^3.17.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 /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-06-25T18_16_56_033Z-debug-0.log
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1

我以前部署过盖茨比网站,这次没有做任何不同的事情。这个网站只是一个简单的网页,带有一些CSS。

出现错误的原因是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-26 13:46:26

此错误是与react版本相关的对等依赖冲突,它为您如何尝试解决该冲突提供了指导:

国家预防机制错误!修复上游依赖冲突,或者重试npm错误!这个命令有--强制,或者--遗留的--对等点-- npm错误!接受不正确的(并且可能被破坏的)依赖项解析。

要在Netlify上执行此操作,可以使用旗子环境变量。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72756395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档