angular-cli: ng new fails with "Schematic input does not validate against the Schema"

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [x ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Node Version:

$ node --version
v10.12.0

NPM Version:

$ npm --version
6.4.1

Angular Version:

$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.0.2
Node: 10.12.0
OS: darwin x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.10.2
@angular-devkit/core         7.0.2
@angular-devkit/schematics   7.0.2
@schematics/angular          7.0.2
@schematics/update           0.10.2
rxjs                         6.3.3
typescript                   3.1.3

OS: MacOS Mojave

Repro steps

ng new ng7app

The log given by the failure

Schematic input does not validate against the Schema: {“name”:“ng7app”} Errors:

Data path “” should have required property ‘version’.

Desired functionality

I would like to generate a new Angular Workspace.

Mention any other details that might be useful

if i provide a ‘version’, then i get a different error :

$ ng new ng7app --version 7
Cannot read property 'entries' of undefined

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 56 (2 by maintainers)

Most upvoted comments

I had the same error when I used underscores in the new app name instead of hyphens:

npm new my_new_app >>> Fails npm new my-new-app >>> Succeeds

I had the same error when I used underscores in the new app name instead of hyphens:

I had the same error when one of the name-parts was digits, e.g. prototype-1234. Changing it to prototype-s1234 works. So here it’s a case of a bad regex.

I removed node_modules folder in users/{user name} and ng new [appname] now working.

Con la nueva actualización del Angular CLI debes de especificar con que tipo de versión trabajarás

ng new project-name --version=7.0.4 o ng new project-name --version=7.0.2

Saludos

Apparently if your project name has a “_” or “-” (underscore or hyphen) it tends to throw this error. I removed the special chars and it worked ok.

image

@westdabestdb Si te fijas replique tu ejemplo y si trabaja, te recomiendo que resinstalar el CLI de forma global.

in my case using @angular/cli 7.2.3

ng new angular-7-test failed with error

Schematic input does not validate against the Schema: {"name":"angular-7-test","version":"7.2.3","routing":true,"style":"scss"}
Errors:

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

ng new angular7testsuccess

I had the same error when I used underscores in the new app name instead of hyphens: npm new my_new_app >>> Fails npm new my-new-app >>> Succeeds

So it was the underscores. This worked for me. Thanks! (Still, it’s strange)

Hi, For resolve this error uninstall @schematics/angular package or remove @schematics directory from node_modules directory then install a previous version. For example: npm i @schematics/angular@0.7.0 --save-dev

@SantiPrll Hello, thank you for help but now I get this error. ng new freeng --version=7.0.2 Could not find (undefined)

hi @alexeagle thanks,

i didn’t have a rogue angular.json file, but i did have a rogue ‘local’ install in my Projects folder, must of forgot the -g sometime previously.

Anyway, Seems to have been resolved by removing the unneeded node_modules folder.

HI, This issue may be resolved by applying the following command in cmd.

npm i @schematics/angular@latest --save-dev

after applying this no need to write version after angular 7 project name just write ng new ang-project-name

For me, before, I updated npm : “npm update” and after run : “ng new projetc-teste --version=7.3.6”

I was facing the same issue… The problem for me was , I was using an underscore when creating the directory name. I was using “ng new Test_Angular”. Then I changed it to “ng new Test-Angular” and it worked for me

using @SantiPrll comment it worked for me

I deleted the -3 at the end of my project name and then it worked. 😃

ng new my-project-3 ----> Doesn’t work ng new my-project-three ----> Works

3 things you should check if you face problem on ng new

  1. check the directory name - should not have alphanumeric and special characters.
  2. type ng --version in node cmd, check whether all package is clear without showing error on the package version or else install those packages.
  3. if cmd shows error on @angular\cli then delete c:\users\username\Appdata\Roaming\npm\node_modules@angular\cli and then install it, it will work. if you feel appdata is missing in the folder then it is in hidden, u should do C: -> Organize -> Folder Options -> View -> Hidden files and folder -> Show hidden files…

Hope this will help you…

I’m closing this issue as the original issue has been resolved.