Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create angular 5 project in angular cli 6.0.1

Tags:

angular6

My angular cli version is 6.0.1 and node version is 8.11.1.

image of version

How to create or add a new project of angular 5.

If I use ng new [project_name] then the project is downloading that is of angular 6.

like image 869
Pradip Rupareliya Avatar asked May 12 '18 10:05

Pradip Rupareliya


People also ask

How do I create a project with specific Angular version?

After complete the installation, just create new angular project into your specific folder that you recently install angular. Ex: d:\projects\demo\ . Now create angular project using the command ng new Project_name and it will create your specific angular version Project.

What is the cli version for Angular 5?

Whenever you want to create a new workspace just make sure you have that version installed globally. Remember, Angular CLI was version 1.7 for Angular 5.


2 Answers

I stumbled upon this scenario too.
Here is my solution to it.

Unfortunately we are at the CLI's mercy, as the best way to create a new Angular project scaffolding.
Considering ng new {app_name} does not support a version flag.
Our aim would be to get the right CLI version installed.

The following steps helped me workaround this:

  1. Create a new folder: mkdir ng-5-cli && cd ng-5-cli
  2. Initialise NPM npm init
  3. Install older Angular CLI: npm i @angular/[email protected] --save-dev
  4. For some reason now the ng compiler assumes this is a angular project directory and does not allow running ng new here.
  5. Step out of the current directory: cd ..
  6. Use the absolute path to Angular cli in the directory from step #1.

For example /ng-5-cli/node_modules/.bin/ng new some-ng5-app

This should create a new application with Angular version 5.x .

You can always install other cli versions and create custom softlinks for them to use in future.

like image 166
ashish.gd Avatar answered Sep 28 '22 03:09

ashish.gd


I have found a good explanation and the steps how to do -

https://blog.angularindepth.com/angular-5-or-angular-6-yes-please-d71b08b5e59b

1) Install Angular 6 CLI globally:

npm install -g @angular/cli@6

2) Create a folder called ng5 to house all of your new Angular 5 applications:

md ng5
cd ng5

3) In your ng5 folder create a new local npm application by using:

npm init -y

4) Install Angular 5 CLI locally using:

npm install @angular/cli@1

5) Now you MUST delete the local package.json file. If you don’t, Angular CLI will complain when you try use ng new. This is because it will think you are trying to create a new application inside an existing Angular CLI application.

6) Create your new Angular 5 application:

ng new my-ng5-app
like image 38
Kanchan Avatar answered Sep 28 '22 03:09

Kanchan