8

I'm attempting to upgrade several Angular 4 apps to Angular 5 using the upgrade instructions on https://angular-update-guide.firebaseapp.com. I've attempted it on 3 different Windows 10 systems, but they all fail.

Below is the type of error that I get. Although, it's not consistently about @angular/common every time. It seems to randomly complain about different packages. I can run the command 3 times in a row and it will say 'No matching version found' for 3 different packages.

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @angular/common@'5.0.0'
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

The command being run is:

npm install @angular/animations@'^5.0.0' @angular/common@'^5.0.0' @angular/compiler@'^5.0.0' @angular/compiler-cli@'^5.0.0' @angular/core@'^5.0.0' @angular/forms@'^5.0.0' @angular/http@'^5.0.0' @angular/platform-browser@'^5.0.0' @angular/platform-browser-dynamic@'^5.0.0' @angular/platform-server@'^5.0.0' @angular/router@'^5.0.0' typescript@2.4.2 rxjs@'^5.5.2'

Keeping up with the frequent changes to Angular and upgrading apps to current versions has been an ongoing struggle that I think needs some attention. In most cases, I've had to perform extensive manual editing to package.json and package-lock.json, or I've simply started the project over from scratch and imported my code. Upgrading should be much easier/automated.

Dan Rullo
  • 81
  • 1
  • 2
  • Possible duplicate of [How to update from Angular 4 to Angular 5](https://stackoverflow.com/questions/47070229/how-to-update-from-angular-4-to-angular-5) – Sangwin Gawande Nov 13 '17 at 13:18

2 Answers2

17

Had the same issue and fixed it with 3 installs, though I think it may have just been the single quotes around the version number

I had typescript 2.6, so I rolled back (their instructions seem specific about the version, listing it twice)

npm install typescript@2.4.2 --save-exact

Upgrade all angular components. This is same as the upgrade guide but @latest instead of the versions.

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest

Finally installed rxjs last

npm install rxjs@^5.5.2
snomad
  • 333
  • 1
  • 3
  • 7
  • in VS cmd prompt I ran `tsc -v` which returned `version 2.3.5`. I ran `npm install typescript@2.4.2 --save-exact` and that returned `+ typescript@2.4.2 added 1 package in 1.166s`, after this I ran `tsc -v` again and it returned `version 2.3.5` again . What is `install typescript` command doing in this case? – tony09uk Jan 09 '18 at 22:05
  • Can you share your package.json? You may want to edit that directly. As another potential solution, Microsoft just recently released a Visual Studio template that uses angular cli to manage the client. https://learn.microsoft.com/en-us/aspnet/core/spa/angular?tabs=visual-studio – snomad Jan 10 '18 at 23:13
  • Since posting this question I have made a lot of changes,m so I feel my current package.json will not be an accurate representation. So I shall rephrase my question. Will the typescript version that I install via npm be the version that is used by VS when I am working on my project or does visual studio manage its own version of Typescript? – tony09uk Jan 11 '18 at 11:45
  • 1
    That is a great question. Unfortunately I don't have an answer.My guess is that it depends on how the process is started. That is, VS can be configured to start multiple ways (see Properties\launchSettings.json, https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments). – snomad Jan 12 '18 at 18:23
  • 1
    Was able to get the original line to work just fine by removing the single quotes, as you had suspected. – msg45f Jan 28 '18 at 01:01
0

Removing the quotes around the version numbers did it for me.

Alternatively, you can try the approach below as mentioned here.

$ npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@5.0.0
Jules Dupont
  • 7,259
  • 7
  • 39
  • 39