How to Install an Older Version of Angular for Legacy Projects
To install an older version of Angular, install the matching CLI version globally with npm install -g @angular/cli@<version>, scaffold a new project with --skip-install, then explicitly install the exact @angular/* package versions to ensure compatibility with legacy codebases.
When maintaining legacy Angular applications or starting new projects that must align with existing code standards, you often need to install an older version of Angular rather than the latest release. The Angular repository maintains strict version alignment between the CLI schematics and core framework packages, making it essential to follow a specific workflow when working with historical releases.
Why You Need Version-Aligned CLI and Core Packages
Angular's CLI schematics are version-specific, meaning the ng generate, ng build, and migration commands only understand the project file formats from their corresponding release. Using a mismatched CLI version can result in an angular.json configuration containing unsupported options or builder versions that fail during compilation.
According to the Angular source code in adev/src/content/tools/cli/setup-local.md, the CLI must be installed globally at the specific version required by your project. The repository's README.md further confirms that the CLI version used to generate a project must match the Angular core version to ensure schematic compatibility.
Step-by-Step Guide to Install an Older Version of Angular
Check Supported Versions in the Angular Repository
Before installing, consult the actively supported releases table in adev/src/content/reference/versions.md. This file maintains the official list of supported Angular versions and their corresponding Node.js requirements. The repository's .nvmrc file (currently pinning Node 22.22.0) indicates the development version used by the main branch, but older Angular releases often require earlier Node LTS versions.
Install the Matching Angular CLI Version
Install the CLI globally at the exact version you need, or use npx for a one-off installation without polluting your global npm store:
# Global install (replace <v> with exact version, e.g., 14.2.12)
npm install -g @angular/cli@<v>
# One-off install using npx
npx -p @angular/cli@<v> ng new my-legacy-app --skip-install
As documented in adev/src/content/tools/cli/setup-local.md, the global install command ensures that ng commands invoke the correct schematic set for your target version.
Scaffold the Workspace Without Auto-Installing Dependencies
Create the workspace using --skip-install so you can control exact package versions manually:
ng new my-legacy-app --skip-install
cd my-legacy-app
This prevents the CLI from automatically installing the latest Angular packages, which would override your version requirements.
Pin Exact Angular Core Package Versions
Explicitly install each @angular/* package at your target version. This pattern is shown in adev/src/content/tools/libraries/angular-package-format.md and the repository's README.md:
npm install \
@angular/core@<v> \
@angular/common@<v> \
@angular/compiler@<v> \
@angular/platform-browser@<v> \
@angular/platform-browser-dynamic@<v> \
@angular/router@<v> \
@angular/forms@<v>
For additional Angular libraries like Material, install them at the same version:
npm install @angular/material@<v> @angular/cdk@<v>
Verify the angular.json Configuration
Open angular.json to confirm the CLI version matches your installation. As described in adev/src/content/reference/configs/workspace-config.md, the file should contain:
{
"cli": {
"version": "<v>"
}
}
This verification ensures that builder versions and schematic collections align with your installed packages.
Complete Installation Example for Angular 14
Here is a complete, runnable example targeting Angular 14.2.12:
# Install CLI globally at version 14.2.12
npm install -g @angular/cli@14.2.12
# Create workspace without installing dependencies
ng new legacy-app --skip-install
cd legacy-app
# Install exact Angular 14.2.12 core packages
npm install \
@angular/core@14.2.12 \
@angular/common@14.2.12 \
@angular/compiler@14.2.12 \
@angular/platform-browser@14.2.12 \
@angular/platform-browser-dynamic@14.2.12 \
@angular/router@14.2.12 \
@angular/forms@14.2.12
# Optional: Add Angular Material for v14
npm install @angular/material@14.2.12 @angular/cdk@14.2.12
# Verify CLI version in config
cat angular.json | grep '"cli"'
# Start the development server
ng serve
Using npx for One-Off Legacy Installs
If you cannot modify global npm packages, use npx to invoke a specific CLI version without installation:
npx -p @angular/cli@14.2.12 ng new legacy-app --skip-install
cd legacy-app
# Then proceed with explicit package installation as shown above
This approach is documented in the repository's setup guides and prevents version conflicts between different projects on the same machine.
Key Source Files in the Angular Repository
Understanding the following files helps verify version compatibility when you install an older version of Angular:
adev/src/content/reference/versions.md– Contains the actively supported Angular versions table and Node.js compatibility matrix.README.md– Documents the global CLI installation command and basicng newworkflow.adev/src/content/tools/cli/setup-local.md– Provides the officialnpm install -g @angular/cliinstructions.adev/src/content/tools/libraries/angular-package-format.md– Shows the canonicalnpm install @angular/corepattern for specific versions.adev/src/content/reference/configs/workspace-config.md– Describes theangular.jsonstructure and CLI version verification..nvmrc– Pins the Node.js version (currently22.22.0) used by the main branch; older Angular releases require matching Node LTS versions.
Summary
- Install the matching CLI version globally using
npm install -g @angular/cli@<version>or usenpxfor temporary access, as the CLI schematics must align with your target Angular version. - Use
--skip-installwhen runningng newto prevent automatic installation of latest packages, allowing you to pin exact versions inpackage.json. - Explicitly install core packages (
@angular/core,@angular/common,@angular/compiler, etc.) at the same version to ensure runtime compatibility. - Verify
angular.jsoncontains the correct CLI version in the"cli"section to confirm builder alignment. - Check
adev/src/content/reference/versions.mdin the Angular repository to confirm Node.js compatibility for your chosen Angular version.
Frequently Asked Questions
How do I find which Angular versions are still supported?
Consult the adev/src/content/reference/versions.md file in the Angular repository, which maintains the official table of actively supported releases and their corresponding Node.js version requirements. This document is updated regularly to reflect the current LTS (Long Term Support) status of each Angular version.
Can I use the latest Angular CLI with an older project?
No, you should not use the latest CLI with an older project. The CLI schematics and builders are version-specific; using a mismatched CLI can generate an angular.json configuration with unsupported options or fail to recognize legacy project structures. Always install the CLI version that matches your project's Angular core version.
What Node.js version should I use with older Angular versions?
Each Angular version requires a specific Node.js LTS version. Check the compatibility matrix in adev/src/content/reference/versions.md to find the supported Node range for your target Angular version. The repository's .nvmrc file (currently 22.22.0) only reflects the development version for the main branch, not legacy releases.
How do I install additional Angular libraries like Material for legacy projects?
Install additional Angular libraries at the same version as your core Angular packages to ensure API compatibility. For example, if using Angular 14.2.12, run npm install @angular/material@14.2.12 @angular/cdk@14.2.12. This prevents version mismatches that can cause build errors or runtime exceptions in legacy applications.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →