Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Angular-CLI with Angular v4.x

I've installed Angular-CLI using this command

npm install -g @angular/cli

but I've realized that it has installed Angular v5.1.3 but I need to use Angular 4.x.

How can I install the last version of Angular-CLI with the last version of Angular 4.x?

like image 203
vcRobe Avatar asked Jan 12 '18 17:01

vcRobe


Video Answer


2 Answers

you can use

 npm i @angular/[email protected] -g

if you want package JSON file with the versions lower than 5.

Starting with v1.5 of the Angular CLI, we have added support for Angular v5.0.0 and will generate v5 projects by default. see link

like image 183
Schattenjäger Avatar answered Sep 18 '22 13:09

Schattenjäger


You can use a simple hack: locally install @angular/[email protected] and use it to generate a new project.

To do that, follow these steps:

  1. In a new folder create a simple nodejs project with the command npm init
  2. Locally install angular-cli 1.4 under this project: npm install @angular/[email protected]
  3. Delete the node project files except the newly created node_modules folders: this means that you will need to delete package.json and any other that it has may be created like karma.js etc.
  4. Now you can create a new Angular 4 project with the command ng new <project name>. It will use the local version of angular-cli previously installed.
  5. You may now remove the node_modules folder.

Then, if you cd in your new project you will have a fully Angular 4 project.

like image 37
hubert Avatar answered Sep 20 '22 13:09

hubert