升级后ng服务无法启动

时间:2019-01-18 13:27:04

标签: angular

我已更新角度,并出现以下错误:

The serve command requires to be run in an Angular project, but a project definition could not be found.

我已经完成以下操作:

D:\IntelliJProjects\springboottests\src\main\frontend2>ng update @angular/cli --migrate-only
    Package not installed: "@angular/cli". Skipping.
    We analyzed your package.json and everything seems to be in order. Good work!

D:\IntelliJProjects\springboottests\src\main\frontend2>ng serve
The serve command requires to be run in an Angular project, but a project definition could not be found.

D:\IntelliJProjects\springboottests\src\main\frontend2>

我在包含package.json和angular-cli.json的文件夹中。

我已经尝试过stackoverflow的建议,但是没有帮助。

我的版本:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.12.2 (cli-only)
@angular-devkit/core         7.2.2 (cli-only)
@angular-devkit/schematics   7.2.2 (cli-only)
@angular/tsc-wrapped         0.5.2
@ngtools/json-schema         1.1.0
@ngtools/webpack             1.10.2
@schematics/angular          7.2.2 (cli-only)
@schematics/update           0.12.2 (cli-only)
rxjs                         6.3.3
typescript                   3.2.4
webpack                      2.2.0

有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

确保您正在从Angle Application根文件夹中运行ng serve命令。 如果已经存在,则可以尝试以下方法:

  • 通过ng -v获取您的angular cli最新版本
  • ng更新@ angular / cli-仅迁移--from = [angular cli版本]

来自this SO thread

答案 1 :(得分:0)

这是因为angular.json文件 只需运行ng update @ angular / cli