You are currently viewing How to create a specific version of the Angular project using CLI?

How to create a specific version of the Angular project using CLI?

Sharing is caring!

Need to create specific Angular app versions? You’ve come to the right place. As developers, we sometimes need to generate older Angular projects or downgrade existing applications. This article will teach you three simple methods to create Angular apps of any version you require while avoiding issues with global packages.

By leveraging the Angular CLI, NPX, or modifying package.json directly, you can swiftly produce applications in legacy Angular releases or control the versioning of current projects. Whether your goal is supporting outdated codebases or experimenting with different releases, I’ll explain multiple approaches to building Angular projects across a range of versions.

Follow along as we dive into each technique with actionable code snippets and implementation details. Soon you’ll have the version management knowledge to install exact Angular editions for any development needs that arise. Let’s get started!

  1. Using NPM
  2. Using NPX
  3. Using package.json file
  1. Using NPM

To create a project using NPM follow these steps:

Step 1: Create a new folder of your choice inside any drive.

Step 2: Open Command Prompt from that folder or just type cmd into your created folder address bar in Windows and hit enter).

Step 3: Now type the Angular version-specific command. For example to create a project of Angular version 13 type the following command.

npm install @angular/cli@13

or even specific in version 13 as:

npm install @angular/[email protected]

Step 4: After the completion of the installation, create a new Angular Project where you just installed Angular CLI.

ng new your_project_name

Step 5: Congratulations you now have your Angular version-specific project.

  1. Using NPX

Since npm version 5.2.0 npx is pre-bundled with npm. npx is a Node.js package runner. You can use this package runner without affecting the globally installed package registry (-g). To create a project type the following command.

npx @angular/cli@13 new your_project_name
  1. Using package.json file

If you want to downgrade your project. For example version 14 to version 13.

  1. Create/edit a package.json file.
  2. Define the Angular version you want to install or change all versions to your specific version.
  3. Run npm install it will create a project with a specified version.

Frequently Asked Questions (FAQs)

Q: How to create an Angular project with a specific version?

A: Use the @angular/cli npm package to generate projects with a specific Angular version. For example:

npm install @angular/cli@13 
ng new my-app

This will create an Angular 13 project.

Q: How to create an Angular project with version 8?

A: Specify version 8 of @angular/cli:

npm install @angular/cli@8
ng new my-app

Q: How to change the version of an Angular project?

A: Edit your package.json file to update the Angular packages to a different version, then run npm install. However, this may cause breaking changes, so it’s best to create a new project instead.

Q: Will all Angular features work in older versions?

A: Some newer features may not be supported in older Angular versions. Check the documentation to see what features were introduced in each release. You may need to polyfill certain capabilities if using an older version.

Q: Can I create projects with Angular version below 9?

A: Yes, but the steps would be slightly different. For versions below 9, you would install a specific @angular/cli npm package version rather than reference the Angular version.

Q: Does NPX work for any Angular version?

A: NPX works for Angular CLI version 6 and above. For older versions, you would still use NPM but reference the specific @angular/cli package version.

Q: What happens if I change Angular versions in an existing project?

A: This can cause breaking changes. It’s best to create a new project for different major versions. For minor updates, check the changelog and test rigorously.

Q: How do I know what version of Angular CLI I have globally installed?

A: Run ng version in your terminal/command prompt to output the globally installed CLI version.

Source: Stackoverflow

Keywords: check angular cli version, how to check angular version, how to check angular version of project, install angular specific version, install specific version of angular cli, angular cli install specific version, npm install angular cli specific version, install angular cli specific version, angular version command, check cli version, angular version check, install specific angular cli version, how to check angular version of project, angular cli create new project, how to install specific version of angular, angular cli new project, npx specific version, start new angular project.

Sharing is caring!

This Post Has One Comment

Leave a Reply