I installed via npm
several angular packages, and I have this warning:
@angular/[email protected] requires a peer of typescript@>=3.1.1 <3.3
but none is installed.
You must install peer dependencies yourself.
a) What is the difference between peer- and just dependency?
b) What should I install now to fix the warning ?
I mean, suppose I install a package "P" I know, but this P needs X, Y and Z. Should I install them manually? It does not seem very cool...
Actually, I installed Angular
, but Angular
needs compiler-clr
and the latest needs typescript
.
When I saw this warning, I installed npm install typescript
it installed me the version [email protected]
, but this *** compiler-clr
needs typescript@<3.3
, what should I do now?
Should I analyse what version of typescript were out before 3.3
, and so on, for all the warnings of this type?
Peer dependencies are almost like normal dependencies, but instead of defining a strong requirement between A and B (i.e the project you're developing and the project it depends on), they're meant to specify a package that your code requires, but doesn't directly require it.
you need to change that to npm --logevel=error install , and that will suppress the WARN message and Team Foundation Server will stop complaining about it.
By default, npm install will install all modules listed as dependencies in package.
Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.
a) A peer dependency of another dependency means that the former can be installed alongside the latter, while a dependency of another dependency installs the former with the latter without requiring you to do anything.
Check out this StackOverflow question for full info on the difference between peerDependencies
and dependencies
.
b) The @angular/compiler-cli
(GitHub) package has a peer dependency of typescript
from versions 3.1.1
to below 3.3.x
.
I suggest that you run npm i -D typescript@~3.2.0
in your project's root to install v3.2.x
in the minor
semver (semantic versioner) range (check out NPM's semver guide for more info).
The npm i -D typescript@~3.2.0
command does the following:
i
indicates that you're installing a package.-D
flag indicates that you're installing a package and adding it to the devDependencies
object in your package.json
typescript@~3.2.0
indicates that you want to install the typescript
package in the version range of 3.2.x
, where x
is a number.
@~x.x.x
indicates that you want to install
"Approximately equivalent to [the] version [specified (x.x.x in this case)]" - npm-package.json | npm Documentation
If you still have any questions or if you don't understand a thing, please comment with your queries on this answer. I'll try to help by responding as soon as possible. Hope this answer helps.
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