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?
You can use
npm install -g @angular/cli@1.5
This should install
Angular 4.4.6
and will useangular-cli 1.5.5
This was the latest version before 5 came in
Using
npm install -g @angular/cli
you will install the lastest stable version of the@angular/cli
. So once you create an angular project using thecli
there will be apackage.json
file, to specify the version of angular to use for the project change the version you would like to use in the package.json file. Then runnpm install
.I think downgrade your cli is not good idea becuase they are fixing lots of bug. You can specific your angular in package.json file. don't depend on your cli.
Edit
First install latest version from your cli. Then Specify the version you want in the 'dependencies' section of your package.json. For example if you want Angular 4.3.4 then you can edit you package.json file like
Also change your
devDependencies
now run npm install
After finishing install you should see your version by
ng -v
command like thisYou can use a simple hack: locally install
@angular/cli@1.4
and use it to generate a new project.To do that, follow these steps:
npm init
npm install @angular/cli@1.4
node_modules
folders: this means that you will need to deletepackage.json
and any other that it has may be created likekarma.js
etc.ng new <project name>
. It will use the local version of angular-cli previously installed.node_modules
folder.Then, if you
cd
in your new project you will have a fully Angular 4 project.This means you installed
@angular/cli
globally on your computer so that you can use theng
commands from anywhere on a console.You need to create a new Angular Project using
ng new my-project-name
which will generate all the basic files you need for an Angular project.In these files, you will find a
package.json
file that contains all the library references you need in your project. It should have the angular package by default at version 5+.To be 4.X.X like you want, you need to find the best
@angular/cli
version compatible with the Angular version you want (I advise using 1.5.0 or less for@angular/cli
).you can use
if you want package JSON file with the versions lower than 5.