GAURAV
GAURAV

Reputation: 703

How to create project for different versions of Angular 2|4|5|6

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?

Upvotes: 0

Views: 1046

Answers (2)

alt255
alt255

Reputation: 3576

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

Upvotes: 0

Suresh Kumar Ariya
Suresh Kumar Ariya

Reputation: 9774

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.

Upvotes: 0

Related Questions