9

My project was running on dot net core 2.0 with angular 4.2. I update it to latest angular (5.0.0). Since then, exception is thrown at this line in a startup.cs Configure method.

 app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
 {
     HotModuleReplacement = true
 });

Fails here with error

Error: Version of @angular/compiler-cli needs to be 2.3.1 or greater. 
Current version is "5.0.0".
at Object.<anonymous> (D:\Personal\Code\PettlyUi\PettlyUi\node_modules\@ngtools\webpack\src\index.js:27:11)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)

The Same error is thrown when I use webpack from the command line too.

I tried the same with new projects also and it consistently fails. Is this some kind of bug or I have not updated properly.

Command used for upgrading:

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 typescript@latest
Code Name Jack
  • 2,856
  • 24
  • 40
  • what is the version of `angular-cli` which is installed globally? use the command `ng -v` and update the post – Aravind Nov 03 '17 at 23:20
  • cli version was 1.5, However I solved my problem finally after hours of struggle, this command saved me, npm install --save-dev @ngtools/webpack@latest looks like ngtools/webpack needed to be updated. what I was trying earlier is just this, npm install --save webpack@latest Sorry for the trouble guys – Code Name Jack Nov 03 '17 at 23:24
  • but I still have a doubt around the error message "needs to be 2.3.1 or greater. Current version is "5.0.0".", does it qualify as a bug – Code Name Jack Nov 03 '17 at 23:27
  • No. Are you available in TeamViewer?. – Aravind Nov 04 '17 at 11:12
  • cant as it is official code, but can you please suggest how it can be justified – Code Name Jack Nov 04 '17 at 11:36
  • uninstall all the node_modules from global and local folder and clean the cache install fresh set and try – Aravind Nov 04 '17 at 11:49
  • no that doesn't help, nd anyways I fixed the issue, my concern now is why it says needs greater than 2.3.1 and current version is 5.0.0. even though 5.0.0 is greater than 2.3.1 – Code Name Jack Nov 04 '17 at 13:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/158219/discussion-between-aravind-and-code-name-jack). – Aravind Nov 04 '17 at 14:21

1 Answers1

13

Since there are no answers, I will write what fixed my problem

This issue may occur because Angular is updated to version 5.0.0 but ngtools is still older. This causes webpack command to fail. Use this command to update webpack to latest,

npm install --save-dev @ngtools/webpack@latest

The error incorrectly tries to point to old compiler-cli version, which is clearly not the case.

Code Name Jack
  • 2,856
  • 24
  • 40