3

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?

Vikas
  • 11,859
  • 7
  • 45
  • 69
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
  • its asking for `angular.json`, not `.angular.json` – Jota.Toledo Jun 03 '18 at 15:04
  • Check if the versions are updated in package.json. Also did you try reloading your workspace, esp if you are using VSC as your editor. – Avinash Jun 03 '18 at 15:06
  • I use notepad++ as editor. I get the `Workspace needs to be loaded` error even if the name of the file is without the dot – Iter Ator Jun 03 '18 at 15:08
  • 1
    i dont think you need to manually change the file name _.angular.cli.json_ to _angular.json_. Once you update and if its successful automatically the configuration should migrate from _.angular.cli.json_ to _angular.json_. Check if the versions are updated in package.json and run npm install once. This can of some help for you - [Angular Update](https://update.angular.io/) – Avinash Jun 03 '18 at 15:20
  • It is not mentioned anywhere to change the file name. But even with the new name, I get the `Workspace needs to be loaded` error – Iter Ator Jun 03 '18 at 15:23
  • did you check the versions in _package.json_ if @angualr/cli is updated and tried _npm install_?. – Avinash Jun 03 '18 at 15:28
  • I have angular/cli 6 in my package.json – Iter Ator Jun 03 '18 at 15:34

1 Answers1

6

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

Yakov Fain
  • 11,972
  • 5
  • 33
  • 38