Update Local Angular CLI Version

I am writing this post to share my experience with the below error –  and how I managed to resolve it.

Message I received –

Your global Angular CLI version (9.1.5) is greater than your local
version (7.3.8). The local Angular CLI version is used.

To disable this warning use “ng config -g cli.warnings.versionMismatch false”.

Please note – I could have disabled it, but that would not have solved the problem. I wanted to keep it same and latest.

 

Once I faced when I installed the latest version of Angular Core with version 9.1.5 and my Angular cli was still 7.3.8 in package.json file.

We normally install / update to latest by running following NPM command

$ npm install g @angular/cli

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

It shows the message as I started above –

Your global Angular CLI version (9.1.5) is greater than your local
version (7.3.8). The local Angular CLI version is used.

To disable this warning use “ng config -g cli.warnings.versionMismatch false”.

Solution

As the project uses the local node_module packages which have version listed in package.json. To update pacakge.json to the latest version we will use a utility npm-check-updates

# Install npmcheckupdates
$ npm i g npmcheckupdates
# Run npmcheckupdates with u, will upgrade package.json
$ ncu u
# Install updated packages
$ npm install
After running $ ncu  you can check updated versions available.
Some may get the below error:
ERROR in ./src/polyfills.ts
Module not found: Error: Can’t resolve ‘core-js/es6/reflect’ in ‘C:\project\Sunny\billingsoftware\src’
ERROR in ./src/polyfills.ts
Module not found: Error: Can’t resolve ‘core-js/es7/reflect’ in ‘C:\project\Sunny\billingsoftware\src’
To fix this, open polyfills.ts
From
/** Evergreen browsers require these. **/
import ‘core-js/es6/reflect’;
import ‘core-js/es7/reflect’;
To
/** Evergreen browsers require these. **/
import ‘core-js/es/reflect’;
//import ‘core-js/es7/reflect’;
Voila: It worked.
Conclusion: Using npm-check-updates we can easily update to latest packages locally without getting into the trouble to go run install commands for each package.

Leave a Reply