How to setup new Angular project with specific Version locally

how-to-setup-angular-project-with-specific-version-image-feature.png

When you have updated Angular CLI using npm install -g @angular/cli[@version], everytime you create Angular project using the ng new command, the project is generated with Angular version corresponding to that Angular CLI version. In this tutorial, we’re gonna show you 2 ways how to setup new Angular project with specific Version.

Overview

This is our current Angular CLI version:

how-to-setup-angular-project-with-specific-version-current-version

We have 2 ways to setup new Angular project with specific Version:
– using npx => don’t need to install Angular CLI locally
– using local Angular CLI => generate a local folder for node_modules

Setup new Angular project with specific Version using npx

Install npx

Run command: npm i -g npx

Setup new Angular project

Now, if we want to create Angular 6 project, just run the command:
npx -p @angular/cli@6.2.7 ng new angular-6-foo

Run command ng --version on project folder, the result would be like:

how-to-setup-angular-project-with-specific-version-angular-6-version

Check package.json file:

Setup new Angular project with specific Version using local Angular CLI

Install local Angular CLI

Go to the folder that you want to contain all Angular projects with the specific version, run command (for example, we use Angular 4):
npm install @angular/cli@1.4.9

node_modules folder will be generated.

Setup new Angular project

On the folder that you’ve installed Angular CLI, run the familiar command:
ng new angular4foo

Now run the ng --version command on project folder, the result would be like:

how-to-setup-angular-project-with-specific-version-angular-4-version

Check package.json file:



By grokonez | November 24, 2018.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*