Iter Ator
Iter Ator

Reputation: 9269

Migrating from Angular5 to Angular6, angular.json is not updated

I would like to migrate from Angular5 to Angular6, following this answer

I tried to execute this three commands, to update .angular-cli.json to angular.json:

npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli

Unfortunately, there is still no angular.json. If I try to run ng serve, I get this error:

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

So I renamed .angular-cli.json to angular.json. But it did not help:

Schema validation failed with the following errors: Data path "" should NOT have additional properties(project). Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project). at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (C:\projects\my-app\node_modules\@angular-devkit\core\src\workspace\workspace.js:173:42) at MergeMapSubscriber._tryNext (C:\projects\my-app\node_modules\rxjs\internal\operators\mergeMap.js:122:27) at MergeMapSubscriber._next (C:\projects\my-app\node_modules\rxjs\internal\operators\mergeMap.js:112:18) at MergeMapSubscriber.Subscriber.next (C:\projects\my-app\node_modules\rxjs\internal\Subscriber.js:103:18) at MergeMapSubscriber.notifyNext (C:\projects\my-app\node_modules\rxjs\internal\operators\mergeMap.js:141:26) at InnerSubscriber._next (C:\projects\my-app\node_modules\rxjs\internal\InnerSubscriber.js:30:21) at InnerSubscriber.Subscriber.next (C:\projects\my-app\node_modules\rxjs\internal\Subscriber.js:103:18) at MapSubscriber._next (C:\projects\my-app\node_modules\rxjs\internal\operators\map.js:92:26) at MapSubscriber.Subscriber.next (C:\projects\my-app\node_modules\rxjs\internal\Subscriber.js:103:18) at SwitchMapSubscriber.notifyNext (C:\projects\my-app\node_modules\rxjs\internal\operators\switchMap.js:122:26)

Therefore I tried to run ng update @angular/core, but I get this error:

Workspace needs to be loaded before it is used.

What do I wrong?

Upvotes: 3

Views: 4037

Answers (1)

Yakov Fain
Yakov Fain

Reputation: 12378

You can't manually rename the file .angular-cli.json into angular.json. They have different schemas hence your errors.

Delete the existing dir node_modules. Make sure you run npm install @angular/cli and ng update @angular/cli from the root dir of your project. If the file angular.json is not created, read the output on the console - it should give you some errors.

If this doesn't help, just generate a new project using Angular CLI 6 and copy the src dir and assets from your existing project into the newly generated one.

I blogged about my experience of upgrading Angular 5 projects to Angular 6 here: https://yakovfain.com/2018/05/16/how-i-migrated-a-dozen-of-projects-to-angular-6

Upvotes: 6

Related Questions