I need to update my project from Angular 4 to Angular 5+ ,
I need to change all following dependencies to Angular 5+.
I also updated Angular CLI to 1.5.0.
I tried to create new project but it seems to create only Angular 4 project.
ng new NG5_Project
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"core-js": "^2.4.1",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
}
What am I doing wrong.
CLI Config :
If you want to simply upgrade your angular4 project to angular 5 do the following.
This worked for me.
http://www.talkingdotnet.com/upgrade-angular-4-app-angular-5-visual-studio-2017/
Check Angular blog out
In the article, an update guide is mentioned.
You can find it here: https://angular-update-guide.firebaseapp.com/
Also, you can update your
angular-CLI
to1.5.0
which will create angular v5 project. You can compare the differences with yours.This solution is for visual studio 2017 using angular template
Use Node.js command prompt or Open PowerShell. Navigate to project directory and use the command dir to check if the
package.json
file exists.Close the Visual Studio instance and run the command
npm install -g npm-check-updates
then following output should appearThen use the command ncu -u The following package should update to the latest version
If the packages are still pointing to Angular 4, then delete the
package-lock.json
and follow the above-given steps again.Webpack is used as module bundler by Visual Studio. Webpack uses AotPlugin to compile the Angular 4 apps, now Webpack no longer uses Aotplugin for Angular 5. It now uses AngularCompilerPlugin.So open
webpack.config.js
and replace all occurrences of AotPlugin with AngularCompilerPlugin.Open ClientApp/boot.server.ts file and replace the following line of code (line no.22).
const zone = moduleRef.injector.get(NgZone);
with,
const zone: NgZone = moduleRef.injector.get(NgZone);
Source link
Here's the correct answer, and it's super simple.
Follow the official Angular upgrade guide.
You'll fill out a short form selecting which version of Angular you are on and which version you want to upgrade to. It then shows you the list of necessary steps to take to perform the upgrade. You should follow this guide for all upgrades. (Please upvote before navigating away) :)
https://update.angular.io/
To upgrade your Angular 4 to Angular 5
Open your webpack.config.js
Add the below code inside ContextReplacementPlugin
Elaborating a bit more, this helped me with BOTH the global as the PROJECT LOCAL upgrade.
The exact guide lines are (of course) in https://update.angular.io/.
Global:
Project local:
Then:
This may be needed (and won't hurt): $npm audit fix
$ npm install typescript@2.4.2 --save-exact
Source:
https://update.angular.io/ will show you the best route.
The major difference is when you still use the 'http' module. You can (or need) to migrate from http to the httpclient module. In most cases, this is quite easy.