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

时间:2019-06-16 14:00:18

标签: angular

我正在尝试从书中复制Angular 5 src代码。 ng serve和。我有The serve command requires to be run in an Angular project, but a project definition could not be found

文件夹结构为

 06/15/2019  11:13 PM             1,665 .angular-cli.json
 06/15/2019  11:21 PM    <DIR>          node_modules
 06/15/2019  11:13 PM             1,496 package.json
 06/15/2019  11:13 PM    <DIR>          src
 06/15/2019  11:13 PM               382 tsconfig.json

我尝试过ng update --force --all

1 个答案:

答案 0 :(得分:0)

典型的angular.json具有以下结构。所以我认为您的angular.json文件缺少projects属性

    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
      "someproject": {
        "root": "",
        "sourceRoot": "src",
        "projectType": "application",
        "prefix": "app"
         ...//other thing
   }
  }