When I run npm i
on my current react project, I get the following warning regarding react peerDependency:
npm WARN [email protected] requires a peer of react@^16.0.0-0 < 16.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
While in my package.json, I am using latest version of react:
"react": "^16.7.0"
I am new to node and npm. I would like to know what is the good practice for installing npm peerDependencies:
1.) Can the warnings for lower versions be ignored if updated version is already specified in package.json.
2.) As per https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/ and https://github.com/npm/npm/issues/6565
npm provides dependency isolation and peerDepencies needs to be manually installed, so should I install all 3 versions of react but I fear that will break the import statements.
3.) If none of the above two, which version should I use in package.json. P.S. there are many more dependencies in my package.json which might require latest version also.
A peer dependency means that a package is applicable to used with a particular version of the dependency & wouldn't work as intended if you exceed the specified version.
In your case [email protected]
requires a version of React less than 16.4.0, [email protected]
requires any version of React 15 and the same for [email protected]
.
You would need to downgrade from React 16.7.0, but that can break your application if you are using 16.7.0 features, or you could remove the packages and use another one or write the package's logic from start yourself.
Tip: always make sure to read package dependencies on npm website before actually considering to use a package for your project.
Taking Danyal's answer further, you can upgrade formsy-react and remove react-tap-event-plugin:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With