23

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.

2
  • 3
    Even moderators closed the question, please add any further information you found Shruti, more people are on this issue. Commented Apr 19, 2020 at 22:39
  • 2
    I'm seeing the same thing. If I change my project name to lower case, it appears to work. But my project name is an acronym, so upper case is correct. Is this a bug? Commented Apr 28, 2020 at 15:11

8 Answers 8

23

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-._~]*$"
Sign up to request clarification or add additional context in comments.

5 Comments

This solved the issue (after I closed and reopened VS Code). But, being the edited file under node_modules, is it overwritten to the original each time I run npm install?
@FrySimpson To answer your question, running npm install does not revert the modifications.
@Yassir, thanks. In order to have modifications "remembered" I suppose i have to remember to keep the package-lock.json file if i manually delete node_modules in order to share my code with someone.
Note this requires a restart. I lost a bit of time for not thinking of that initially.
How do you do this if the "node_modules" folder is normally not on git. Sure you could make an exception for this one file but...
7

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.

Comments

3

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.

Comments

2

It is working fine on stackblitz, sometimes VS code behaves strangely. Try closing VS code and opening again, that helps most of the times in these cases

working example https://stackblitz.com/edit/angular-dhtbbh

Comments

0

Checks if {} are in the correct position. In my case I did:

{ "configurations": { "production": { ... } }, **"stage": { ... }** }

The correct way was:

{ "configurations": { "production": { ... }, **"stage": { ... }** } }

Comments

-1

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.

Comments

-2

Change the project name in all the .json files

Comments

-3

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

1 Comment

This doesn't actually solve the issue, especially when you find the issue a long time after starting the project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.