Angular-cli: Unable to create new project with a number in its name

Created on 4 May 2018  路  24Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 6.0.0
Node: 9.9.0
OS: darwin x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.0
@angular-devkit/core         0.6.0
@angular-devkit/schematics   0.6.0
@schematics/angular          0.6.0
@schematics/update           0.6.0
rxjs                         6.1.0
typescript                   2.7.2

Repro steps

  • npm i -g @angular/cli
  • ng new ng-6-playground

Observed behavior

Schematic input does not validate against the Schema: {"name":"ng-6-playground","version":"6.0.0","newProjectRoot":"projects","skipInstall":false,"linkCli":false,"skipGit":false,"commit":null}
Errors:

  Data path ".name" should match format "html-selector".

Desired behavior

Should be able to create a new project using the CLI.

Most helpful comment

Just got the same error with an underscore in the project name.

All 24 comments

Actually looking into this more, it appears that there's an issue with creating a project with a number in it's name.

If I create a project with ng new ng-playground it works. But as soon as I add a number like ng new ng-6-playground the error in the original post appears.

Just got the same error with an underscore in the project name.

That's always been the case. The project name is a html selector, every part of it (split by -s) must start with a letter. This is a restriction we're considering removing with the new workspace but decided to keep the 1.x behaviour the same for now.

It's interesting... I do believe that the error message on Windows 10 Pro is more user friendly than the one on Ubuntu 16.04...

Ubuntu:
`Schematic input does not validate against the Schema: {"name":"ng_clean_20180507","version":"6.0.0","newProjectRoot":"projects","skipInstall":false,"linkCli":false,"skipGit":false,"commit":null}
Errors:

Data path ".name" should match format "html-selector".
`

Win10:
Project name "ng_clean_20180607" is not valid. New project names must start with a letter, and must contain only alphanumeric characters or dashes. When adding a dash the segment after the dash must also start with a letter.
ng_clean_20180607

I get the "Schematic input does not validate" error on both Windows 7 and Mac OS X Sierra.

So the friendly message on Windows must , indeed, be a Windows 10 only thing.

only "abcdEfgHijklmnopQrstuvxyZ" ubuntu 16.04

@hansl I have the issue putting any project name.

For example, see the console message after I put the command ng new section:

Schematic input does not validate against the Schema: {"name":"section/","version":"6.0.7","newProjectRoot":"projects","skipInstall":false,"linkCli":false,"skipGit":false,"commit":null}
Errors:

  Data path ".name" should match format "html-selector".

Ubuntu version: 16.04.4 LTS

My Angular packages details:

Angular CLI: 6.0.7
Node: 8.4.0
OS: linux x64
Angular:
...

Package | Version

@ angular-devkit/architect | 0.6.7
@ angular-devkit/core | 0.6.7
@ angular-devkit/schematics | 0.6.7
@ angular/cli | 6.0.7
@ schematics/angular | 0.6.7
@ schematics/update | 0.6.7
rxjs | 6.2.0
typescript | 2.7.2

angular app name rules, there can only be a letter after '-', like app-two. you can not use app-2 as the project name.

Thanks @junweipan your answer helped me to find solution. Today I installed Angular CLI: 7.0.3 and it threw me the same error.

I renamed the project name removing the underscore and it worked.

seems it doesn't support underline, so make sure your project name not including underline.

that is a very nasty bug , better do some workaround
i wasted a lot of time figuring out that what was the case
at last i have to come to this page and see for myself what all things are allowed .
but good to go now :)

underscore [ _ ] in name of the project also threw this error

ng-v6-playground will work!

oui c'est 莽a la bon r茅ponse merci beaucoup pour cette information

In my case there was an error while I tried to add the project name an underline "_". Once I removed, the command worked.

for me 15-puzzle-generator didn't work so I changed it to fifteen-puzzle-generator which did馃榿
angular cli 7.3.6

Just got the same error with an underscore in the project name.

thank you I got the same error and resolve it

almost an year after the underscore issue on project name is still there

As of today, the error is still here

Angular CLI: 7.3.9
Node: 11.6.0
OS: darwin x64
Angular:
...

Package Version

@angular-devkit/architect 0.13.9
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@schematics/angular 7.3.9
@schematics/update 0.13.9
rxjs 6.3.3
typescript 3.2.4

I had the same error as well, removing underscore in the project's name fixed the issue.

underscore [ _ ] in name of the project also threw this error

I couldn't agree with you any more TT

It seems that "_" is the main culprit... I removed and was able to create a new project.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings