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

前端 未结 23 923
-上瘾入骨i
-上瘾入骨i 2020-11-28 01:10

I have travis-ci integrated with my GitHub account (https://github.com/pradeep0601/Angular5-Router-App).

When I updated @angular/cli versio

相关标签:
23条回答
  • 2020-11-28 01:59

    I had the same problem, and what I did that works for me was:

    1. Inside package.json file, update the Angular CLI version to my desired one:

      "devDependencies": { ...
        "@angular/cli": "^6.0.8",
        ...
      }
      
    2. Delete the node_modules folder, in order to clean the project before update the dependencies with:

      npm install
      
      ng update @angular/cli
      
    3. Try to build again my project (the last and successful attempt)

      ng build --prod
      
    0 讨论(0)
  • 2020-11-28 01:59

    For me, the issue was that I have an angular project folder inside a rails project folder, and I ran all the angular update commands in the rails parent folder rather than the actual angular folder.

    0 讨论(0)
  • 2020-11-28 02:01

    It works for me:

    Delete folder node_modules

    Run command: npm install

    ( If it does not work for the first time, repeat this 2 or 3 times, Its funny but it works for me. )

    0 讨论(0)
  • 2020-11-28 02:02

    For me the problem was because of global @angular/cli version and @angular/compiler-cli were different. Look into package.json.

    ...
    "@angular/cli": "6.0.0-rc.3",
    "@angular/compiler-cli": "^5.2.0",
    ...
    

    And if they don’t match, update or downgrade one of them.

    0 讨论(0)
  • 2020-11-28 02:03
    ~/Desktop $ ng serve
    

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

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

    at WorkspaceLoader._getProjectWorkspaceFilePath (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:37:19)
    at WorkspaceLoader.loadWorkspace (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:24:21)
    at ServeCommand._loadWorkspaceAndArchitect (/usr/lib/node_modules/@angular/cli/models/architect-command.js:180:32)
    at ServeCommand.<anonymous> (/usr/lib/node_modules/@angular/cli/models/architect-command.js:47:25)
    at Generator.next (<anonymous>)
    at /usr/lib/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/@angular/cli/models/architect-command.js:3:12)
    at ServeCommand.initialize (/usr/lib/node_modules/@angular/cli/models/architect-command.js:46:16)
    at Object.<anonymous> (/usr/lib/node_modules/@angular/cli/models/command-runner.js:87:23)
    

    This is because I haven't choose the Angular project directory.

    It should be like:

    ~/Desktop/angularproject $ ng serve

    0 讨论(0)
提交回复
热议问题