How to update angular project from 5 to 7

Viewed 8963

I am trying to update my project from angular 5 to angular 7. For this first is update @angular/cli gloabaly and locally then I installed @angular/cli locally then update ng module and other related commands.

Now, I check my ng --version it is showing me angular 7, but my project is not running its always throwing below error: enter image description here

Below is my script in package.json file:

"scripts": {
"start": "cross-env NODE_ENV=development webpack-dev-server --port=9000 -- 
   content-base wwwroot/",
   "build": "cross-env NODE_ENV=development webpack --progress",
   "prod": "cross-env NODE_ENV=production webpack  --progress"
 }
2 Answers

Steps of updating angular latest version 7:

1 ) You need to update your angular cli.

npm uninstall -g angular-cli
npm cache clean or npm cache verify 
npm install -g @angular/cli@latest

(c.f https://cli.angular.io/)

2) You need to upgrade your project version as per suggestion of angular update guide. Angular update guide website link Angular version upgrade guide website link (Click here)

3) On this website select your older version and your desired latest version after that click on 'Show me how to update'

4) After click on this button website provide a number of steps. You need to follow this step to upgrade your Angular version

If you're doing this in 2020, make the following steps:

npm uninstall -g angular-cli

npm cache clean 

npm cache verify 

npm install -g @angular/cli@7.3.6(or the specific version of Angular 7)

Check your package-lock.json. It should be working for you. If it still doesn't work, use the following commands:

ng update @angular/cli

ng update @angular/core

npm audit fix

npm start

Also check https://update.angular.io/.

Related