升级angular-cli版本后报错:
- The serve command requires to be run in an Angular project, but a project definition could not be found.
- compiler_cli_1.readConfiguration is not a function
1、升级angular-cli到最新版
我的angular版本是1.7.4
在项目的根目录下依次执行一下命令
npm uninstall angular-cli
npm cache clean
npm install @angular/cli@latest
升级之后查看版本
2、版本更新完成之后,npm start启动项目,发现报错:The serve command requires to be run in an Angular project, but a project definition could not be found.
在网上找到解决方案:ng update @angular/cli --migrate-only --from=1.7.3
(资料来源:https://stackoverflow.com/questions/53096996/angular-cli-error-the-serve-command-requires-to-be-run-in-an-angular-project-b)
执行以上命令后启动项目,还是报错:compiler_cli_1.readConfiguration is not a function
这是版本更新不彻底导致的,可执行命令:ng update @angular/compiler-cli --force
,强制更新(资料来源:https://blog.csdn.net/qq_38904077/article/details/89259218)
再启动项目,编译成功。