3

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.

2
  • Updating Angular CLI. Commented Jul 31, 2017 at 13:12
  • @r-richards the link you provided is not an answer to the question as it is not saying how to upgrade the breaking changes that happend from 1.0.4 to 1.2.4 but only how to reinstall/update the @angular/cli npm package in the project Commented Aug 1, 2017 at 7:00

3 Answers 3

1

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 
Sign up to request clarification or add additional context in comments.

1 Comment

upvote for including the Windows command: rmdir /S/Q node_modules dist
0

Updating minor version of AngularCLI v.1.x.x

NOTE: If you are updating to 1.0 from a beta or RC version, check out the 1.0 Update Guide.

AngularCLI doesn't have support for automatic update of the CLI version and the dependencies on existing projects. However, keeping up to the latest version can be quite beneficial as you get the latest features, performance improvements and bug fixes.

I managed to successfully update my project from v.1.1.0 to v1.3.0 with the following steps:

  1. Update the version of the global AngularCLI (follow the steps in this guide)
  2. Create an 'upgrade-project' with the latest version that you recently installed

    $: ng new upgrade-project --skip-install 

    This will create the project in new folder and commit the initial files.

  3. Create and apply an upgrade patch with Git

    You can use plain git format-patch / apply or the support of your favorite IDE (ex. WebStorm)

    $: git format-patch -1 HEAD --stdout > cli-upgrade.patch $: git apply cli-upgrade.patch 
  4. Carefully go through the changes and verify which of them are really needed

    NOTE: you will need to merge the modified files correctly

  5. Re-install the updated dependencies

    • clear the old dependencies before the re-install [recommended]

      $: rm -rf node_modules 
    • install the dependencies

      $: npm install 
  6. Now your update is complete, the next step is to verify that everything is working as expected and fix small things that might got broken along the way

After the CLI was successfully updated together with it's initial dependencies feel free to update also your additional dependencies which are not installed by default (ex. Angular Material).

$: npm update @angular/material ... 

Comments

-1

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/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.