w3resource

Workspace npm dependencies

The Angular Framework, Angular CLI, and components used by Angular applications are packaged as npm packages and distributed via the npm registry.

You can download and install these npm packages by using the npm CLI client, which is installed with and runs as a Node.js® application. By default, the Angular CLI uses the npm client.

Alternatively, you can use the yarn client for downloading and installing npm packages.

package.json

Both npm and yarn install the packages that are identified in a package.json file.

The CLI command ng new creates a package.json file when it creates the new workspace. This package.json is used by all projects in the workspace, including the initial app project that is created by the CLI when it creates the workspace.

Initially, this package.json includes a starter set of packages, some of which are required by Angular and others that support common application scenarios. You add packages to package.json as your application evolves. You may even remove some.

The package.json is organized into two groups of packages:

  • Dependencies are essential to running applications.
  • DevDependencies are only necessary to develop applications.

Dependencies

The packages listed in the dependencies section of package.json are essential to running applications.

The dependencies section of package.json contains

  • Angular packages: Angular core and optional modules; their package names begin @angular/.
  • Support packages: 3rd party libraries that must be present for Angular apps to run.
  • Polyfill packages: Polyfills plug gaps in a browser's JavaScript implementation.

To add a new dependency, use the ng add command.

Angular packages

The following Angular packages are included as dependencies in the default package.json file for a new Angular workspace. A complete list of Angular packages can be seen in the Angular API reference.

PACKAGE NAME DESCRIPTION
@angular/animations Angular's animations library makes it easy to define and apply animation effects such as page and list transitions.
@angular/common The commonly-needed services, pipes, and directives provided by the Angular team. The HttpClientModule is also here, in the @angular/common/http subfolder.
@angular/compiler Angular's template compiler. It understands templates and can convert them to code that makes the application run and render. Typically you don't interact with the compiler directly; rather, you use it indirectly via platform-browser-dynamic when JIT compiling in the browser.
@angular/core Critical runtime parts of the framework that are needed by every application. Includes all metadata decorators, Component, Directive, dependency injection, and the component lifecycle hooks.
@angular/forms Support for both template-driven and reactive forms.
@angular/http Angular's legacy HTTP client, which was deprecated in version 5.0 in favor of @angular/common/http.
@angular/platform browser Everything DOM and browser related, especially the pieces that help render into the DOM. This package also includes the bootstrapModuleFactory() method for bootstrapping applications for production builds that pre-compile with AOT.
@angular/ platform browser dynamic Includes providers and methods to compile and run the app on the client using the JIT compiler.
@angular/router The router module navigates among your app pages when the browser URL changes.

Support packages

The following support packages are included as dependencies in the default package.json file for a new Angular workspace.

PACKAGE NAME DESCRIPTION
rxjs Many Angular APIs return observables. RxJS is an implementation of the proposed Observables specification currently before the TC39 committee, which determines standards for the JavaScript language.
zone.js Angular relies on zone.js to run Angular's change detection processes when native JavaScript operations raise events. Zone.js is an implementation of a specification currently before the TC39 committee that determines standards for the JavaScript language.

Polyfill packages

Many browsers lack native support for some features in the latest HTML standards, features that Angular requires. Polyfills can emulate the missing features. The Browser Support guide explains which browsers need polyfills and how you can add them.

The package.json for a new Angular workspace installs the core-js package, which polyfills missing features for several popular browsers.

DevDependencies

The packages listed in the devDependencies section of package.json help you develop the application on your local machine. You don't deploy them with the production application.

To add a new devDependency, use either one of the following commands:

npm install --dev <package-name>
yarn add --dev <package-name>

The following devDependencies are provided in the default package.json file for a new Angular workspace.

PACKAGE NAME DESCRIPTION
@angular devkit/ build angular The Angular build tools.
@angular/cli The Angular CLI tools.
@angular/ compiler cli The Angular compiler, which is invoked by the Angular CLI's ng build and ng serve commands.
@angular/ language service The Angular language service analyzes component templates and provides type and error information that TypeScript-aware editors can use to improve the developer's experience.
@types/... TypeScript definition files for 3rd party libraries such as Jasmine and Node.js.
codelyzer A linter for Angular apps whose rules conform to the Angular style guide.
jasmine/... Packages to support the Jasmine test library.
karma/... Packages to support the karma test runner.
protractor An end-to-end (e2e) framework for Angular apps. Built on top of WebDriverJS.
ts-node TypeScript execution environment and REPL for Node.js.
tslint A static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors.
typescript The TypeScript language server, including the tsc TypeScript compiler.

Previous: TypeScript Configuration
Next: The Ahead-of-Time (AOT) compiler



Follow us on Facebook and Twitter for latest update.