2017-06-22 91 views
0

我試圖在Linux機器上運行角度爲2的應用與ng serve。它不工作。但我試過npm run start命令。它工作正常。 當我嘗試ng serve命令時,我收到以下消息。npm運行開始工作,而ng服務不工作

As a forewarning, we are moving the CLI npm package to "@angular/cli" 
with the next release, 
which will only support Node 6.9 and greater. This package will be 
officially deprecated 
shortly after. 

To disable this warning use "ng set --global 
warnings.packageDeprecation=false". 

You have to be inside an angular-cli project in order to use the 
generate command. 

我想在項目文件夾內的這個命令也。

我的package.json文件如下

{ 
     "name": "xxxxxx", 
     "version": "1.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": "^4.1.3", 
     "@angular/common": "4.1.3", 
     "@angular/compiler": "4.1.3", 
     "@angular/core": "4.1.3", 
     "@angular/forms": "4.1.3", 
     "@angular/http": "4.1.3", 
     "@angular/platform-browser": "4.1.3", 
     "@angular/platform-browser-dynamic": "4.1.3", 
     "@angular/router": "4.1.3", 
     "@angular/upgrade": "4.1.3", 
     "angular2-jwt": "0.2.3", 
     "chart.js": "2.5.0", 
     "core-js": "2.4.1", 
     "moment": "2.18.1", 
     "ng2-charts": "1.5.0", 
     "ngx-bootstrap": "1.6.6", 
     "primeng": "^4.0.0-rc.3", 
     "rxjs": "5.4.0", 
     "ts-helpers": "1.1.2", 
     "zone.js": "0.8.11" 
     }, 
     "devDependencies": { 
     "@angular/cli": "1.0.4", 
     "@angular/compiler-cli": "4.1.3", 
     "@types/jasmine": "2.5.47", 
     "@types/node": "7.0.22", 
     "codelyzer": "3.0.1", 
     "jasmine-core": "2.6.2", 
     "jasmine-spec-reporter": "4.1.0", 
     "karma": "1.7.0", 
     "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": "1.2.1", 
     "protractor": "5.1.2", 
     "ts-node": "3.0.4", 
     "tslint": "5.3.2", 
     "typescript": "2.3.3" 
     } 

} 

我已經試過ng generate module [name]。它也不起作用給出上述相同的信息。這可能是什麼原因?

+0

哪裏是你'.angular-cli.json'文件? –

+0

它在同一個目錄 – nilashan

+0

使用角度CLI,ng服務不會工作,您將不得不使用npm run start –

回答

0

錯誤說明了這一切,你可能在你的角度應用程序上方的一個目錄。

試試這個

cd my-app 
ng serve 
+0

我在應用程序目錄中。其中package.json和其他文件存在。 – nilashan

+1

您使用哪個版本的@ angular/cli創建了此應用程序? 似乎是這樣,你的服務器有一個角度cli的舊角度cli。 當他們發佈版本1時,他們將其移至@angular項目。 確保您的服務器具有新的角度cli –

+0

angular-cli:1.0.0-beta.28.3 – nilashan