0

In my window 8 system, Angular CLI 6.1.1 has been installed. I want to create projects for Angular2, Angular4, Angular5 nd Angular6. But when I create a project using the below command:

ng new demo

in pachage.json it adds the following code:

    {
  "name": "demo2",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.1",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

What should I do to create projects for Angular 2|4|5|6?

GAURAV
  • 647
  • 6
  • 18

2 Answers2

0

In Package.json, we can only configure only one Angular Version either 2/4/5/6. As for as i know, Angular CLI doesn't support multiple Angular projects in single codebase.

Suresh Kumar Ariya
  • 9,516
  • 1
  • 18
  • 27
  • I want to create different projects of different versions, but every time when I run "ng new demo", then it creates the project for only Angular6, I don't want to create multiple Angular projects in a single codebase, instead of it, I want to create different projects with different versions. – GAURAV Jul 31 '18 at 07:40
  • You can downgrade your Angular CLI Local version to 1.x. You can configure package.json to Version 2/4/5. – Suresh Kumar Ariya Jul 31 '18 at 07:45
  • if you want to star angular 2 please reffer this link http://csharp-video-tutorials.blogspot.com/2017/06/angular-2-tutorial-for-beginners_12.html – Akhil Jul 31 '18 at 07:54
  • I have downgrade my Angular CLI version to 1.4.9. When I run "**ng new demo**" then it gives an error "You cannot use the **new** command inside an Angular CLI project." – GAURAV Jul 31 '18 at 07:57
  • After you downgrade. Did you check angular version using ng -v?. Also You need to create a new project from the New folder, not in the existing angular project. – Suresh Kumar Ariya Jul 31 '18 at 09:19
0

you can use npx to temporarily download a certain version of ng cli and use it to create the scaffolding e.g npx -p @angular/cli ng new hello-world-project

alt255
  • 3,396
  • 2
  • 14
  • 20
  • Where should I specify the version of Angular CLI in your given command – GAURAV Jul 31 '18 at 08:15
  • specify the version by inserting `@` at end of package name e.g `npm install -g angular-cli@1.0.0-beta.14` – alt255 Jul 31 '18 at 08:19
  • When I downgrade my Angular CLI version to **1.4.9** it gives an error when I run **ng new demo** - "You cannot use the **new** command inside an Angular CLI project." – GAURAV Jul 31 '18 at 09:11