Angular CLI command issue: "Unknown option: '--spec'"
Asked Answered
D

8

20

I am running this command:

C:\Users\Murali\my-first-app>ng g c abcde5 --dry-run -t -s --spec=false

I am receiving the following error:

Unknown option: '--spec'

How can I correct my command to avoid this?

Dessert answered 6/6, 2020 at 7:46 Comment(0)
R
48

You can find all options here. Answering you question replace --spec=false by --skip-tests. If it won't working please provide the AngularCLI version

Riffraff answered 6/6, 2020 at 7:50 Comment(1)
just --skipTests option (without '=true') works well tooLondoner
P
12

You can also use --skip-tests flag to skip generating .spec files. For more detail, you can use ng g c --help, this will give you further details

Portage answered 6/6, 2020 at 13:37 Comment(0)
C
7

Instead of

--spec=false 

use

--skip-tests

Don't use --skipTests=true because

Support for camel case arguments has been deprecated and will be removed in a future major version.

enter image description here

Came answered 22/2, 2021 at 13:45 Comment(0)
J
4

If you are using Angular CLI version 3, replace

--spec=false

with

--skipTests=true
Jos answered 31/8, 2020 at 12:3 Comment(0)
S
2
ng generate component componenetname --skipTests=true --inlineStyle=true

was replaced by

ng generate component componenetname --skip-tests --inline-style

in angular CLI 14

Shonda answered 21/7, 2022 at 19:29 Comment(0)
A
1

Use rather than --sepc false :

--skip-tests

In the old version of angular, it's was working right but in the new version this not working with me anymore.

Arnulfoarny answered 22/4, 2022 at 20:39 Comment(0)
S
0

ng g c componentname --skipTests true

In the newer version of Angular CLI --spec is replaced with --skipTests.

This is working at my site.

Sprang answered 8/10, 2021 at 7:58 Comment(0)
C
0

With Angular >= 8 you can use:

ng g c component-name --skip-tests --dry-run -s -t

OR

You can edit angular.json to set your global setting to use --skip-tests automatically without having to add it as a flag each time you generate a component with the CLI, by adding the skipTests parameter with value true ie:

{ 
  "projects": {
    "<PROJECT_NAME>": {
      "schematics": {
        "@schematics/angular:component": {
          "skipTests": true
        }
      }
    }
  }
}

To set this globally run:

ng config schematics.@schematics/angular:component.skipTests true

Then, with this config above you can simply use:

ng g c component-name --dry-run -s -t

See this post for further details. Also, for a list of all available options try:

ng g c --help
Chem answered 26/7, 2022 at 6:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.