I have a fresh install of yarn
(via npm install yarn -g
) and tried to install a few packages with
yarn add vue-loader babel-loader style-loader css-loader file-loader webpack
I then got a few warnings during the installation, such as
warning "[email protected]" has unmet peer dependency "vue-template-compiler@^2.0.0".
A sister question (about npm
) on the same subject yields a few answers which suggest to
npm
node_modules
as there is a bug in npm
about handling dependencies.I cannot discard the packages in the warnings, as the webpack
build fails, which leads to me having to manually install them. At the same time, quite a few dependencies were installed so I do not understand why these were not installed.
What does the above warning mean, and why doesn't yarn
install these dependencies on its own?
Running yarn install --check-files or just yarn install can fix the issue and install the missing depecendencies. Explicitly adding to your package. json may also be an option.
UNMET PEER DEPENDENCY error is thrown when the dependencies of one or more modules specified in the package. json file is not met. Check the warnings carefully and update the package. json file with correct versions of dependencies.
Run npm install (or yarn install ) to install prod and dev , as well as peer dependencies. You still may see "unmet peer dependency" warnings, due to installation flow of npm/yarn. Also it won't update lock (shrinkwrap) files or modify package. json, keeping your setup pure and clean.
Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package. This is useful for packages like react that need to have a single copy of react-dom that is also used by the person installing it.
Here is some useful reading on dependency types, and here is info on peer dependencies, but to summarize:
Dependency: A library/package your project needs to run.
Peer dependency: Used to indicate a library/package your project will hook in to.
The package vue-loader
has a peer dependency on vue-template-compiler
- vue-loader
acts as a plugin for vue-template-compiler
Peer dependencies were automatically installed up until npm@3 (which yarn has followed in). This was stopped due to frequently confusing behavior. For example, installing another plugin with a conflicting requirement would result in an error.
We will also be changing the behavior of peerDependencies in npm@3. We won’t be automatically downloading the peer dependency anymore. Instead, we’ll warn you if the peer dependency isn’t already installed. This requires you to resolve peerDependency conflicts yourself, manually, but in the long run this should make it less likely that you’ll end up in a tricky spot with your packages’ dependencies. [Feb 13, 2015]
As per here npm@7 now installs peer dependencies.
For the motivation behind this decision see here
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