Error: Local workspace file ('angular.json

2019-01-03 21:23发布

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

When I updated @angular/cli version from 1.7.4 to 6.0.0-rc.3, the build started failing with an error:

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:37:19)
    at WorkspaceLoader.loadWorkspace (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:24:21)
    at TestCommand._loadWorkspaceAndArchitect (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:177:32)
    at TestCommand.<anonymous> (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:45:25)
    at Generator.next (<anonymous>)
    at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:3:12)
    at TestCommand.initialize (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:44:16)
    at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/command-runner.js:100:23

package.json snippet to better understand the running environment:

    "@angular/cli": "6.0.0-rc.3",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",

19条回答
Explosion°爆炸
2楼-- · 2019-01-03 21:34

If all sorts of updating commando's won't do it. Try deleting package-lock.json. And then run npm install. Did the trick for me after going through tons of update commando's.

查看更多
狗以群分
3楼-- · 2019-01-03 21:34

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.

查看更多
SAY GOODBYE
4楼-- · 2019-01-03 21:35

If you don't know the version ,current project has been made, you can omit --from command and type --migrate-only

ng update @angular/cli --migrate-only

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-03 21:35

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
    
查看更多
We Are One
6楼-- · 2019-01-03 21:37

Try using the below command:

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

It will perform the below

  • Updating karma configuration

  • Updating configuration

  • Removing old config file (.angular-cli.json)

  • Writing config file (angular.json)

Pls note that the above command should be run in the folder where you have file .angular-cli.json and it will be then replaced by angular.json.

查看更多
我只想做你的唯一
7楼-- · 2019-01-03 21:37

Check your folder structure where you are executing the command, you should run the command 'ng serve' where there should be a angular.json file in the structure.

angular.json file will be generated by default when we run the command

npm install -g '@angular/cli' ng new Project_name then cd project_folder then, run ng serve. it worked for me

查看更多
登录 后发表回答