I'm getting the following errors while using the command npm install. I'm new to gatsby and react don't know how resolve.
pegasus@pegasus:~/Documents/MyWebsite/blog-main$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/react
npm ERR! @mdx-js/react@"^1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @mdx-js/react@"^2.0.0" from [email protected]
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! dev gatsby-plugin-mdx@"^5.5.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/react
npm ERR! peer @mdx-js/react@"^2.0.0" from [email protected]
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! dev gatsby-plugin-mdx@"^5.5.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!
npm ERR! For a full report see:
npm ERR! /home/pegasus/.npm/_logs/2023-01-27T07_02_53_230Z-eresolve-report.txt
CodePudding user response:
Seems, version compatibility issue, You have few options to resolve this issue:
Upgrade the version of @mdx-js/react package: You can try to upgrade the version of @mdx-js/react package in your project to a version that is compatible with gatsby-plugin-mdx by running the command npm install @mdx-js/[email protected]
Downgrade the version of gatsby-plugin-mdx package: You can try to downgrade the version of gatsby-plugin-mdx package in your project to a version that is compatible with the current version of @mdx-js/react package by running the command npm install [email protected].
Use --force or --legacy-peer-deps: You can also use npm install --force or npm install --legacy-peer-deps to ignore the peer dependency conflict and install the packages, but this option can lead to unexpected behavior and it's not recommended.
CodePudding user response:
use npm install --legacy-peer-deps