Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: ng new error when I create an angular project

I have this error using ng new project_name:

An invalid configuration file was found ['angular.json']. Please delete the file before running the command.

I am getting this error I don't know how to get the solution.

I uninstalled @angular/cli and installed again

npm clean cache doesnt work too (I dont know if it is problem of my npm version

npm version is 6.4.1    
node version is 8.11.1

what do i need to solve the problem?

like image 632
David Avatar asked Nov 17 '18 17:11

David


People also ask

How do you solve ng error?

To solve the error "ng: command not found", install the angular cli package globally by running npm install -g @angular/cli@latest and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

What is NG new in Angular?

ng new command creates a workspace of given name with a default Angular Application. It provides interactive prompts to set optional configurations. All prompts have default values to choose.

Why is NG not working?

Error 1: 'ng' is not recognized This error is simply telling you that Angular CLI is either not installed or not added to the PATH. To solve this error, first, make sure you're running Node 6.9 or higher. A lot of errors can be resolved by simply upgrading your Node to the latest stable version.

How to create a new project in angular?

The Angular has come a long way since its first version in Angular 2. The creation of a new project is now as simple as installing Angular CLI and running the ng new command. Applies to: Angular 2 to the latest edition of i.e. Angular 8. Angular 9, Angular 10, Angular 11, Angular 12

What is NG New and Ng serve in angular?

We use ng new <name> to create new project. The Angular CLI does an excellent job of downloading all the required libraries and configuring the app. We use ng serve to run our application, which starts the Webpack development server at port 4200.

Do I need to edit angular/CLI after installation?

It has some custom configuration that might be unfamiliar, but it’s not something you’ll need to edit. To create a new project in Angular, we must install angular/cli first. We use ng new <name> to create new project. The Angular CLI does an excellent job of downloading all the required libraries and configuring the app.

How to install angular CLI on dummy project?

CD into your dummy directory and install CLI there (not globally). Just Run: "npm i @angular/cli" Run your "ng new MyProject" command inside of the dummy directory. I tested this twice and it solved the issue for me.


2 Answers

If you are using the terminal of IntelliJ IDEA while there is a angular project already imported in the IDEA, it is the problem of the IDEA.So, open the command promt of your windows and create the project.

I did this and I was able to create the project.

like image 80
Aashman Thing Avatar answered Oct 21 '22 09:10

Aashman Thing


The problem seems to be the _ in project_name resulting in the following error:

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

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

Replace _ e.g. with -.

Further readings:

  • Error when creating new project with Angular-CLI 6.1.2
  • Style Guide
like image 29
pzaenger Avatar answered Oct 21 '22 09:10

pzaenger