This guide outlines the steps to create a new Angular project, considering your preferred package manager and desired Angular version.

Using ‘npm’ (Node Package Manager)

For Angular Version 6 and Above

npx @angular/cli@ new

Replace:

  • with your desired Angular version (e.g., 14).
  • with your preferred project name.
  • Eg. npx @angular/cli@14 new testAngularDemo

Explanation:

  • ‘npx’ is a Node.js package runner that executes packages without global installation.
  • The command downloads and runs the specified Angular CLI version (@angular/cli@) temporarily.
  • ‘new ’ creates a new Angular project using the temporarily downloaded CLI.

For Angular Versions Up to 5

For angular versions up to 5 ‘npx’ commands will not be helpful.

You have to change the global angular cli version and then create a new project.

Ensure @angular/cli is not globally installed. If it is, uninstall it using:
npm uninstall -g @angular/cli

If npm versions above 5:
npm cache verify

For older versions (or for extra cleaning):
npm cache clean --force

Install Specific Angular CLI Version:
npm install -g @angular/cli@

Create Project:
ng new

Using ‘yarn’ (Yet Another Resource Negotiator)

Yarn Version 2 and Above:

yarn dlx -p @angular/cli@ new

Replace:

  • with your desired Angular version (e.g., 14).
  • with your preferred project name.
  • Eg. yarn dlx -p @angular/cli@14 new testAngularDemo

Explanation:

  • ‘yarn dlx’ allows temporary execution of globally installed packages.
  • Similar to ‘npx’, it downloads and runs the specified Angular CLI version on-demand.

Using yarn (Yarn Version Up to 2)

For the Yarn version up to 2 ‘dlx’ commands will not be helpful.
You have to change the global angular cli version and then create a new project.

Uninstall Existing @angular/cli (if globally installed):
yarn global remove @angular/cli

Install Specific CLI Version:
yarn global add @angular/cli@

Verifying Angular CLI Version:
ng --version

Create Project:
ng new

This guide provides clear instructions for both ‘npx’ and ‘yarn’ users, ensuring a smooth project creation experience based on your preferred Angular version and package manager.

Need Help With Angular Development?

Work with our skilled Angular developers to accelerate your project and boost its performance.

Hire Angular Developers

Support On Demand!

Related Q&A