Unable to install react-share on React 18 project and failed deployment on Netlify
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0 || ^17" from react-share@4.4.0
npm install --save --legacy-peer-deps react-share
Unable to install react-share on React 18 project and failed deployment on Netlify
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0 || ^17" from react-share@4.4.0
npm install --save --legacy-peer-deps react-share
First, utilize the advised command npm install --save --legacy-peer-deps react-share
then, in your app root directory create a .npmrc file
lastly add to the file legacy-peer-deps=true
and you're ready to deploy.
The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer deps and proceed with the installation anyway.
npmrc is the configuration file that npm allows to be used globally or user level or project level to optimize your npm environment. npmrc can be configured in four different locations. Globally. Per user. Per project.