“Property Not Allowed” in angular.json error in Visual Studio CODE for Angular CLI version 9.1.1

前端 未结 7 849
一向
一向 2021-01-12 00:40

I created a new project using Angular CLI 9.1.1 and VSCode is giving me the following warning in angular.json file:

Property AM is not allowed
<         


        
相关标签:
7条回答
  • 2021-01-12 00:44

    There are 2 solutions which works for me 100% to overcome from the problem of "Property not allowed" in angular.json file.

    1. Use the command in VS code cmd Ctrl+C choose option Y or

    2. Restart the VS code after editing in angular.json file Hope it will helpful.

    0 讨论(0)
  • 2021-01-12 00:48

    The error is resolved by creating another project but this time using the project name in lowercase letters.

    0 讨论(0)
  • 2021-01-12 00:51

    The packages installed for Angular 10 project have a change in project name structure.

    The file named "schema.json" which come along the packages installed by Angular has a property name "projects" which has the schema structure defined for the project name.

    It looks like this:

    "projects": {
      "type": "object",
      "patternProperties": {
          "^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$": {
          "$ref": "#/definitions/project"
        }
      }
    

    It is configured for lower case project names. You simply have to change the regex so that your uppercase project names can be considered.

    Change the code as below:

    "projects": {
      "type": "object",
      "patternProperties": {
        "^(?:@[a-zA-Z0-9-~][a-zA-Z0-9-._~]*\/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$": {
          "$ref": "#/definitions/project"
        }
      }
    

    The schema.json is located at below path:

    ./node_modules/@angular/cli/lib/config/schema.json

    After the change in schema.json file, restart your Visual Code Editor.

    0 讨论(0)
  • 2021-01-12 00:53

    The schema is case sensitive. If you wish to fix:

    Goto: ./node_modules/@angular/cli/lib/config/schema.json

    At around line 27 you should find:

     "projects": {
          "type": "object",
          "patternProperties": {
            "^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$": {
              "$ref": "#/definitions/project"
            }
          },
    

    Change the regex pattern to allow Uppercase project names:

    "^(?:@[a-zA-Z0-9-~][a-zA-Z0-9-._~]*\/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$"
    
    0 讨论(0)
  • 2021-01-12 00:59

    Change the project name in all the .json files

    0 讨论(0)
  • 2021-01-12 01:01

    The error was gone when change project name and all other occurrences for it in "angular.json" to lowercase letters. no need to create another project or any other stuff.

    0 讨论(0)
提交回复
热议问题