2017-05-30 76 views
0

我正在嘗試使用angular-cli獲取角2項目並運行。我認爲在看到我的Package.json後,角4安裝而不是角2。有人能告訴我正確的做法嗎?需要安裝角2,而不是角4安裝

我用下面的命令來安裝角

npm install -g @angular/cli 
ng new projectname 

的package.json

{ 
    "name": "mrdb.web", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve --proxy-config proxy.conf.json", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "core-js": "^2.4.1", 
    "rxjs": "^5.1.0", 
    "zone.js": "^0.8.4" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.0.6", 
    "@angular/compiler-cli": "^4.0.0", 
    "@types/jasmine": "2.5.38", 
    "@types/node": "~6.0.60", 
    "codelyzer": "~2.0.0", 
    "jasmine-core": "~2.5.2", 
    "jasmine-spec-reporter": "~3.2.0", 
    "karma": "~1.4.1", 
    "karma-chrome-launcher": "~2.1.1", 
    "karma-cli": "~1.0.1", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "karma-coverage-istanbul-reporter": "^0.2.0", 
    "protractor": "~5.1.0", 
    "ts-node": "~2.0.0", 
    "tslint": "~4.5.0", 
    "typescript": "~2.2.0" 
    } 
} 
+0

可能的[使用角度cli安裝特定版本的角度]的副本(https://stackoverflow.com/questions/43344600/installing-a-specific-version-of-angular-with-angular-cli) –

+1

您可以檢查https://stackoverflow.com/documentation/angular2/789/getting-started-with-angular-2/26878/getting-started-with-angular-2-with-node-js-expressjs-的package.json,後端http-example-incl#t = 201705301731505556728但我建議你去angular4 – echonax

+0

從1.0版本開始,Angular/CLI默認使用Angular 4(請參閱[changelog](https://github.com/angular/angular- CLI /斑點/主/ CHANGELOG.md#100-2017-03-24)) – crashmstr

回答

0

編輯您的package.json到:

"dependencies": { 
    "@angular/common": "2.0.0", 
    "@angular/compiler": "2.0.0", 
    "@angular/core": "2.0.0", 
    "@angular/forms": "2.0.0", 
    "@angular/http": "2.0.0", 

然後取出node_modules文件夾rm -rf node_modules和再次運行npm i