tezvyn:

ng new: Your Angular Project Starter Kit

AI-drafted, machine-checkedSource: angular.devbeginner
ng new: Your Angular Project Starter Kit

The `ng new` command is your starter kit for any Angular project. It scaffolds a complete, runnable application with a standard folder structure and dependencies, letting you skip manual setup.

WHY IT EXISTS Starting a modern web application from scratch is complex. You need to set up a build system, transpilers, a development server, testing frameworks, and a sensible file structure. ng new automates this entire process for Angular, providing a consistent and best-practice starting point for every project.

THE MENTAL MODEL Think of ng new as a project cookie cutter. Instead of manually creating dozens of files and configuration settings, you run one command, and it generates a perfectly formed, ready-to-run Angular application. It's the starting pistol for your development race, handling all the setup ceremony for you.

HOW IT WORKS When you run ng new <project-name>, the Angular CLI performs several actions. First, it creates a new directory with the given project name. Second, it generates a standard set of files and folders, including the root module, the main app component, and configuration files like angular.json. Finally, it runs a package manager command like npm install to download all the dependencies, making the project ready to run with ng serve.

WHEN TO USE IT Use ng new every time you start a new Angular project. It is the official and recommended way to initialize an application. You can and should pass flags to customize the setup, such as ng new my-app --routing --style=scss to include the routing module and set the default stylesheet format to SCSS from the beginning.

WHEN NOT TO USE IT You wouldn't use ng new to add a new feature to an existing project; for that, you'd use other ng generate commands. It is designed to create a complete, self-contained Angular workspace, not to modify one that already exists.

ONE CANONICAL EXAMPLE To create a new project named "brainbites-app" that includes routing and uses SCSS for styling, you would run the following command in your terminal: ng new brainbites-app --routing --style=scss. After the command finishes, you can navigate into the new directory (cd brainbites-app) and start the development server with ng serve.

Read the original → angular.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.