serve命令需要在Angular项目中运行,但是找不到项目定义

时间:2018-11-07 00:34:34

标签: node.js angular

我开发了一个应用程序(angular2 nodejs),但是现在当我打开它时,出现以下错误:

  

serve命令需要在Angular项目中运行,但是找不到项目定义。

知道我对cli进行了更新时,我没有发现问题

*Angular CLI: 7.0.4
Node: 10.6.0
OS: win32 x64
Angular: 2.4.10
... common, compiler, compiler-cli, core, forms, http
... platform-browser, platform-browser-dynamic

Package                      Version
------------------------------------------------------
@angular-devkit/architect    <error>
@angular-devkit/core         <error>
@angular-devkit/schematics   <error>
@angular/router              3.4.10
@angular/tsc-wrapped         0.5.2
@ngtools/json-schema         1.1.0
@ngtools/webpack             1.10.2
@schematics/angular          <error>
@schematics/update           <error>
rxjs                         5.5.11
typescript                   2.0.10
webpack                      2.2.0*

这是我的.json包

{
  "name": "angular-src",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "angular2-flash-messages": "^1.0.8",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "^4.1.3",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.28.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}

2 个答案:

答案 0 :(得分:0)

这对我有用,删除或重命名“ angular.json”,然后创建一个新的。

ng update @angular/cli

如果遇到错误,您可能还需要更新打字稿。

也请按照以下步骤操作:https://update.angular.io/

答案 1 :(得分:0)

以下是一些在这种情况下可能有用的提示:

  1. 运行ng serve时请确保您位于根文件夹中
  2. 使用npm install
  3. 使用npm start