I have a Gatsby app.
When I build it locally, it works fine, but when I try to deploy it to Netlify or Gitlab, I get the below error message: Netlify error message:
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/[email protected]
8:44:23 PM: Creating deploy upload records
8:44:23 PM: npm ERR! Found: [email protected]
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/[email protected]
8:44:23 PM: npm ERR! node_modules/@gatsbyjs/reach-router
8:44:23 PM: npm ERR! @gatsbyjs/reach-router@"^1.3.6" from [email protected]
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 [email protected]
8:44:23 PM: npm ERR! node_modules/gatsby-link
8:44:23 PM: npm ERR! gatsby-link@"^4.17.0" from [email protected]
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/[email protected]
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 [email protected]
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: [email protected]
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/[email protected]
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 [email protected]
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 erro message:
$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @mdx-js/[email protected]
npm ERR! Found: [email protected]
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/[email protected]
npm ERR! node_modules/@gatsbyjs/reach-router
npm ERR! @gatsbyjs/reach-router@"^1.3.6" from [email protected]
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 [email protected]
npm ERR! node_modules/gatsby-link
npm ERR! gatsby-link@"^4.17.0" from [email protected]
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/[email protected]
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 [email protected]
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: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"^16.13.1 || ^17.0.0" from @mdx-js/[email protected]
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 [email protected]
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
I have deployed gatsby sites before and have not done anything differently this time. And the site is just a simple page with some CSS.
What could be the reason for there errors?
The error is a peer dependency conflict relating to versions of react, which provides guidance on how you can attempt to resolve it:
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.
To do this on Netlify you can use the NPM_FLAGS environment variable.