我目前在5.2版中有一个关于package.json文件的Angular项目(“ @ angular / core”:“ ^ 5.2.0”)。
由于出现此错误消息,我无法运行ng serve:serve命令需要在Angular项目中运行,但是找不到项目定义。
我的问题是:我是否必须更新当前的Angular版本和软件包才能使用此应用程序?如果是的话,为什么我不能在这种配置下使用它?
任何帮助将不胜感激。
screenshot of the default project
-> PACKAGE.JSON <-
{
"name": "default",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng app",
"build": "ng build && node server.js",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.5",
"@angular/cdk": "^5.2.1",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/flex-layout": "^2.0.0-beta.12",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.1",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@swimlane/ngx-datatable": "^11.1.7",
"chart.js": "^2.7.2",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"ng2-charts": "^1.6.0",
"npm": "^5.7.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "1.6.8",
"@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",
"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 :(得分:0)
移动到有角度的项目位置,然后提供 ng服务,它将起作用。
错误是因为您试图在不同的位置运行角度项目。
cd move_to_your_angular_application_folder
答案 1 :(得分:0)
您不是从根位置(即package.json所在的位置)运行项目。
尝试移动到该位置并运行生成/服务。