我是Angular的新人。
我想知道有没有办法使用Angular CLI来创建Angular 2项目而不是Angular 4或5?
我知道如果我已经有角度项目,我可以手动将其更改为Angular 2,就像这个链接use angular 2 instead of angular 4 with angular-cli
但是我怎样才能在一开始就创建Angular 2项目?如果它需要较低版本的Angular CLI,哪个版本?我怎么能这样做?
请参阅下面的package.json文件:
{
"name": "learnangular2",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"angular2-fontawesome": "^5.2.1",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"bootstrap": "^3.3.7",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
提前谢谢。
答案 0 :(得分:1)
我不明白为什么你需要更老版的角度。 要创建角度v2,您需要一个非常旧版本的angular-cli。
您需要安装订购版本的angular-cli
npm install @angular/cli@1.0.0-rc.2
现在您可以创建角度2.0应用
ng new app-name
在这种情况下,您将使用旧版本的angular-cli。我更好的方法是使用新的angular-cli并在package.json中更改为angular 2.0