How to resolve an 'Invalid format version detected - Expected:[ 1 ] Found: [ 3 ]' error when creating a component in Angular 8?
Asked Answered
W

2

16

I need to create a component in my project in Angular 8, I tried the following command:

ng g c prueba

but it returned back an error as:

Invalid format version detected - Expected:[ 1 ] Found: [ 3 ]

Could you please help me to resolve it?

Weatherbound answered 23/6, 2019 at 21:39 Comment(7)
Seams like the problem comes from the ng commandGallop
Maybe try reinstalling angular cliGallop
I had already done it and it remains the sameWeatherbound
Have you tried with the ng generate component instead of using g cGallop
Yes, i tried with ng generate componentWeatherbound
it should be like this ng g component <name> [options] or try ng g c --help for more detailsPresentationism
I'm actually getting something similar. My theory is that the developer before me did some unorthodox things and the project is in a weird state that Angular/Cli can't deal with. No idea what that might be though.Guttering
G
29

Like in my comment above, I had a similar issue, except mine was reporting that it found 6 instead of 1. Anyway, by luck I took a look in the angular.json file and found that it has an element named version and it was set to 6. So I set it to 1 and the Angular gods smiled down upon me. It now works.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1, // was 6
  ...
}

Now, I really don't know what that field value is for or why it works with 1 and not 6. Will I miss out on other features? No idea.

My Angular CLI version:

Angular CLI: 8.0.2
Node: 8.9.0
OS: win32 x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.1
@angular-devkit/build-angular     0.800.1
@angular-devkit/build-optimizer   0.800.1
@angular-devkit/build-webpack     0.800.1
@angular-devkit/core              8.0.1
@angular-devkit/schematics        8.0.2
@angular/cdk                      8.0.1
@angular/cli                      8.0.2
@angular/fire                     5.2.1
@angular/flex-layout              8.0.0-beta.26
@angular/http                     7.2.15
@angular/material                 8.0.1
@ngtools/webpack                  8.0.1
@schematics/angular               8.0.2
@schematics/update                0.800.2
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

ps: Hey Google, how about some better error messages? Even though this one seems accurate, it was still meaningless.

Guttering answered 25/6, 2019 at 15:9 Comment(0)
S
0

In my case, I was using the wrong version of yarn. After correcting the version with the help of volta, the error was rectified.

Storfer answered 16/1, 2023 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.