Local workspace file ('angular.json') could not be found.

运行 ng serve的时候报了以下的错误

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (D:\nodejs\node_global\node_modules\@angular\cli\models\workspace-loader.js:44:
19)
    at WorkspaceLoader.loadWorkspace (D:\nodejs\node_global\node_modules\@angular\cli\models\workspace-loader.js:31:21)
    at ServeCommand._loadWorkspaceAndArchitect (D:\nodejs\node_global\node_modules\@angular\cli\models\architect-command.js:201:32)
    at ServeCommand.<anonymous> (D:\nodejs\node_global\node_modules\@angular\cli\models\architect-command.js:53:25)
    at Generator.next (<anonymous>)
    at D:\nodejs\node_global\node_modules\@angular\cli\models\architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (D:\nodejs\node_global\node_modules\@angular\cli\models\architect-command.js:3:12)
    at ServeCommand.initialize (D:\nodejs\node_global\node_modules\@angular\cli\models\architect-command.js:52:16)
    at Object.<anonymous> (D:\nodejs\node_global\node_modules\@angular\cli\models\command-runner.js:127:23)

  报错原因:可能是由于angular/cli版本与项目不匹配导致

解决办法:

  升级angular/cli

1.全局卸载angular/cli

npm uninstall -g @angular/cli

2.清理

npm cache verify

3.全局安装angular/cli

npm install -g @angular/cli@latest

4.在项目路径下卸载angluar/cli

npm uninstall --save-dev @angular/cli

5.在项目路径下安装:

npm install --save-dev @angular/[email protected]

6.项目路径下npm install或者yarn install

7.在npm安装后修复问题:

npm audit fix

8.解决与“angular.json”相关的问题:

ng update @angular/cli --migrate-only --from=1.4.9

  

猜你喜欢

转载自www.cnblogs.com/shira-t/p/9759142.html
今日推荐