Should I install all the peer-dependencies manually to remove npm warnings?

25,001

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.
  • The -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.


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.

Share:
25,001
serge
Author by

serge

#asp.net-core #javascript

Updated on July 09, 2022

Comments

  • serge
    serge almost 2 years

    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?

  • serge
    serge about 5 years
    thanks, but you complicates a little bit the point a) I'd talk rather about a peer dependency PD vs dependency D of a package P. You say the difference is PD can be installed, but the D is installed... thinking like this, D also can be installed, and you don't say PD is not installed... and what is the logic PD should exist?
  • serge
    serge about 5 years
    also, I don't understand why angular does install compiler-cli, but does not install typescript if it needs both of them?
  • Edric
    Edric about 5 years
    For the second question, ng new <project-name> automatically adds the typescript dependency to your package.json, which is automatically installed.
  • BraveNewMath
    BraveNewMath about 3 years
    i ran this npm i -D typescript@~3.2.0 but next time i run npm update, i still get the same message. Not sure why