Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Angular projects declare npm packages in package.json, while package-lock.json records the versions installed for the workspace. Add packages with a package manager or, for Angular libraries that provide setup schematics, use ng add. For Angular framework updates, use ng update and follow the Angular Update Guide for the versions you are moving between.

What counts as an Angular npm dependency?

Angular framework packages, the Angular CLI, and application libraries are distributed as npm packages. A generated workspace commonly includes packages such as @angular/core, @angular/common, @angular/router, @angular/forms, @angular/cli, rxjs, and typescript. This is a typical starting set, not a required list for every application. See Angular’s workspace npm dependencies documentation.

Third-party libraries are dependencies too, but their compatibility is determined by each library’s supported Angular versions and installation guidance. Check that guidance before adding or updating a package; Angular’s own documentation cannot establish compatibility for every external library.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How package.json and package-lock.json work together

The workspace’s root package.json configures packages available to projects in that workspace. A generated library can also have its own package manifest. The manifest declares dependencies and acceptable version ranges; it is not a record of every exact package version installed on a particular machine.

package-lock.json records version information for packages installed under node_modules. It works alongside the manifest by preserving the resolved package versions. Keep both files under version control so the declared dependencies and lockfile resolution remain available to the team. Angular explains the workspace files in its file structure documentation.

How to add a dependency to an Angular project

Use ng add when an Angular library supports it

For many Angular libraries, ng add <library> is the most useful route. It installs the published package and can run a schematic to perform library-specific setup, such as scaffolding or configuration changes. The exact changes depend on the package’s schematic.

ng add <library>

Use the package’s actual name in place of <library>. Check its instructions first, especially for required setup or Angular version support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use your package manager for packages without an ng add schematic

Angular supports package-manager workflows, including npm, yarn, pnpm, and bun. Use the package manager configured for your workspace and follow the dependency’s installation instructions. Angular CLI’s ng new documentation lists those package-manager options.

How to update Angular dependencies

Check the update path before changing versions

Use Angular’s interactive Angular Update Guide to select the installed and target versions and get migration steps suited to that upgrade. Angular recommends moving to the latest patch release in the major version you have chosen.

Update Angular CLI and core together

For the basic framework update, Angular documents this command:

ng update @angular/cli @angular/core

For a major-version migration, specify the target major for both packages, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ng update @angular/cli@<target-major> @angular/core@<target-major>

Replace <target-major> with the major version you intend to install. Consult the Update Guide for the exact migration steps and any other affected packages. Angular’s keeping up-to-date guidance covers current-version checks and update workflows.

Update third-party libraries deliberately

ng update can check for library-specific update instructions when libraries support the Angular update mechanism. Update specific packages rather than forcing every dependency to its newest version at once. Peer-dependency mismatches can block an otherwise straightforward update, and library dependencies or interdependencies can affect update order. Resolve those constraints using the library’s own compatibility information and Angular’s migration guidance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why some Angular dependency changes need a major update

Angular’s release policy distinguishes dependency changes that require application modifications from optional dependency updates. Changes requiring application work are introduced in major releases; dependency updates in minor releases are generally optional. Angular core and CLI versions have been aligned since Angular 7.

A major migration may require scripts, refactoring, testing, or changes for updated APIs. Angular characterizes patch releases as low-risk bug fixes, but teams should still validate changes in their own build and test process. See the live versioning and releases policy for current guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular dependency guidance for library authors

If you publish an Angular library, declare Angular packages that your library uses as peerDependencies. This lets the consuming application and library resolve the same Angular module instance. Putting @angular/core in ordinary dependencies can result in a separate Angular instance, which can break the application.

Angular recommends publishing libraries using partial-Ivy compilation. Full-Ivy instructions are not public API, so they are not suitable as a publishing contract. Follow Angular’s library creation and publishing guidance for the current build approach.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.