Update Angular CLI in existing project

Viewed 5935

I'm working on angular-cli 1.0.4 in existing project, I would like to update the version to 1.2.4. What is the best way to uninstall the old one and update to the newer one using npm with effecting my existing project? which updates the version on package.json file.

4 Answers

Look at the Angular-Cli docs. You don't need to create a new project.

Global package:

npm uninstall -g @angular/cli
npm cache clean
# if npm version is > 5 then use `npm cache verify` to avoid errors (or to avoid using --force)
npm install -g @angular/cli@latest

Local project package:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install

Both answers above are correct and are based on the same approach that is the de-facto way as of today.

There are plans from Angular CLI to add an update feature in one of the coming releases.

To update your additional dependencies there is an elegant way by moving them to a second package.json. You can use Yarn Workspaces or package-json-merge for that. More info on my website: https://www.rainerhahnekamp.com/en/updating-angular-cli-dependencies/

Related