3

I used this link to upgrade my simple angular frontend to Angular 7:

Update to Angular 7

While updating i got several warnings for package.json and polyfills.ts files:

UPDATE package.json (1313 bytes)
npm WARN @ngtools/webpack@6.1.5 requires a peer of typescript@~2.4.0 || ~2.5.0 || ~2.6.0 || ~2.7.0 || ~2.8.0 || ~2.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/compiler@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/core@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser-dynamic@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/common@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 69 packages, removed 4 packages, updated 16 packages and moved 2 packages in 43.395s
UPDATE package.json (1315 bytes)
UPDATE src/polyfills.ts (3165 bytes)
npm WARN codelyzer@4.2.1 requires a peer of @angular/compiler@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/core@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser-dynamic@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/common@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

And I also have this error from typescript (3.0.1):

Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined

Can anyone suggest a workaround how to fix these dependency warnings and typescript error? Do I need to change the dependencies manually? If yes I would need an example how to...

Dale K
  • 25,246
  • 15
  • 42
  • 71
student18
  • 538
  • 8
  • 26
  • Angular actually has an official Update tool that you should be using. It makes the update process pretty straightforward and easy. Try [Angular Update](https://update.angular.io/) – SiddAjmera Oct 24 '18 at 08:03
  • Please tell the steps you went through, otherwise it's hard to know. Did you do `ng update` ? What does your packages.json look like? – Qortex Oct 24 '18 at 08:10
  • I did the following ng command from my link: `ng update @angular/cli @angular/core` – student18 Oct 24 '18 at 08:30

2 Answers2

2

The problem is you don't have the latest version for those two packages.

  1. You need to update your package Codelyzer to the latest version. ng update --all should do it, otherwise you can also edit your package.json by hand.

You can see here that the latest version (4.5.0) of this package has been made compatible with Angular 7, so you need to use it instead of your 4.2.1 version.

  1. Same thing for your @ngtools/webpack, you need to use the latest version (see here, it is 7.0.2). It is likely you don't have this one explicitly in your packages.json, so you may just need to do a npm cache clean -f before running ng update.

If this still doesn't work, I suggest you remove your node_modules directory, it will force npm install to rebuild all from the latest versions on the repository, given you correctly updated your package.json (by hand or through ng update).

Qortex
  • 7,087
  • 3
  • 42
  • 59
  • your solution for solving my dependency problems worked well :) I ran `npm cache clean -f` and afterwords `ng update --all`. Anyway I have still the typescript error: `Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined` – student18 Oct 24 '18 at 08:33
  • 1
    Ok, mark as an answer then :) Update Typescript also. And it is another issue, you have to see from what code it is thrown, and it might be another question to ask on StackOverflow if you can't solve it. – Qortex Oct 24 '18 at 08:52
0

Did you remove your old node_modules folder? if not please delete it and also delete package-lock.json if it's there. clean npm cache npm cache clean -f and try installing all the packages

Anjum....
  • 4,086
  • 1
  • 35
  • 45