Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

AM is my project name

screenshot

I want to resolve this warning, but don't know how.

like image 590
Shruti Shree Avatar asked Apr 12 '20 22:04

Shruti Shree


3 Answers

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-._~]*$"
like image 68
ZeusT Avatar answered Nov 14 '22 20:11

ZeusT


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.

like image 24
Mohamed Magdi Avatar answered Nov 14 '22 21:11

Mohamed Magdi


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.

like image 3
Shaikh Nazish Avatar answered Nov 14 '22 21:11

Shaikh Nazish