How to update local Angular CLI version? in package.json file using ‘ncu’ utility

In this short tutorial, we will discuss a very common question on How to keep Angular’s local and global packages updated?

When we create a new Angular project, it lists all its packages used in a separate file called package.json, giving details in JSON format about packages and their current version installed.

How to update Angular Packages?, Install the latest version of Angular CLI, How to check the latest version of packages in package.json file?

You may face following type of error/ warnings if Global and Local versions mismatch.

WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:171-179 “export ‘Ι΅Ι΅inject’ was not found in ‘@angular/core’

One I faced when I installed the latest version of Angular Material with version ~8.1.1 and my Angular core was still ~7.2.0Β in package.json file

 

After the release of the latest version of Angular, we usually update it by running following NPM command which is also there in official docs

So it updates the global version of packages which are not accessible by local projects/ directories.

When we try to create a new Angular project y running the new command as follows:

it shows this message:

Solution

This solution will also resolve the following issue:

An unhandled exception occurred: Could not find the implementation for builder @angular-devkit/build-angular:dev-server

How to update local Angular package.json to latest versions?

As a project use local node_module packages which have version listed in the package.json file. So we need to update those version to latest then run npm update command to update node_modules folder with latest packages.

To update pacakge.json to the latest version we will use a utility npm-check-updates, this checks the latest version for a package then update to the latest version number in package.json. Then we only need to run npm update to update our local node_module folder.

After running $ ncuΒ  you can check updated versions available. Isn’t cool πŸ˜›

Notice: If you face the following issue:

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.6.3 was found instead.

Then install Typescript version 3.6.0 by running following NPM command:

 

Conclusion: Using npm-check-updates we can easily get updated versions available and in the same time also update packages locally without getting into mess to go run install commands for each package.

 

 

Thanks for visiting :) Let me know if you have some suggestions or feedback for this post in the comment section. Looking for any tutorial or demo on FreakyJolly, just drop me a message here

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
2 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
LastDigitsOfPi Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
LastDigitsOfPi
Guest
LastDigitsOfPi

Really useful Guide