23

I installed via npm several angular packages, and I have this warning:

@angular/compiler-cli@7.2.5 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 typescript@3.3.3, 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
  • 13,940
  • 35
  • 121
  • 205
  • You could always install a specific version of typescript (e.g. `npm install typescript@~3.2.0`) – Sustain Feb 18 '19 at 17:20
  • @Sustain, I don't know what version to install. maybe there are 3.2.9, or 3.2.7 before the 3.3. And why should I do it? Imagine I have hundreds of warnings like this. Need I analyse all the dependencies history to just install my angular and start developing my app? – serge Feb 18 '19 at 17:49

1 Answers1

11

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 Stack Overflow 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.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Edric
  • 24,639
  • 13
  • 81
  • 91
  • 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 Feb 19 '19 at 09:29
  • 1
    also, I don't understand why `angular` *does* install `compiler-cli`, but *does not* install `typescript` if it needs both of them? – serge Feb 19 '19 at 09:35
  • For the second question, `ng new ` automatically adds the `typescript` dependency to your `package.json`, which is automatically installed. – Edric Feb 19 '19 at 11:23
  • 1
    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 – BraveNewMath Mar 15 '21 at 19:23