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条回答
我想做一个坏孩纸
2楼-- · 2019-01-03 21:46

I also faced same issue and i just executed below command.

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

It simply delete angular-cli.json and create angular.json. You can find this in logs.

Once you start execution. You will be able to see below logs in your terminal.

        Updating karma configuration
        Updating configuration
        Removing old config file (.angular-cli.json)
        Writing config file (angular.json)
        Some configuration options have been changed, please make sure to update any                                     
        npm scripts which you may have modified.
        DELETE .angular-cli.json
        CREATE angular.json (3599 bytes)
        UPDATE karma.conf.js (962 bytes)
        UPDATE src/tsconfig.spec.json (324 bytes)
        UPDATE package.json (1405 bytes)
        UPDATE tsconfig.json (407 bytes)
        UPDATE tslint.json (3026 bytes)
查看更多
Explosion°爆炸
3楼-- · 2019-01-03 21:48

Check out this link to migrate from Angular 5.2 to 6. https://update.angular.io/

Upgrading to version 8.9 worked for me. enter image description here

查看更多
何必那么认真
4楼-- · 2019-01-03 21:48

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.

查看更多
神经病院院长
5楼-- · 2019-01-03 21:50

I was having this error message inside a docker container. I resolved it adding:

WORKDIR /usr/src

to Dockerfile.

查看更多
Rolldiameter
6楼-- · 2019-01-03 21:52

I just had the same problem.

It's related to release v6.0.0-rc.2, https://github.com/angular/angular-cli/releases:

New configuration format. The new file can be found at angular.json (but .angular.json is also accepted). Running ng update on a CLI 1.7 project will move you to the new configuration.

I needed to execute:

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

This removed .angular-cli.json and created angular.json.

If this leads to your project using 1.7.4, install v6 locally:

npm install --save-dev @angular/cli@v6.0.0-rc.4

And try once again to update your project with:

ng update @angular/cli --migrate-only --from=1.7.4
查看更多
看我几分像从前
7楼-- · 2019-01-03 22:00

For me what worked was creating a new Angular project and just copied the angular.json file in the project that had a problem due to the fact that the angular.json file was missing.

查看更多
登录 后发表回答