This document describes how to set up your development environment to build and test Angular, both
JS and Dart versions. It also explains the basic mechanics of using git
, node
, and npm
.
- Prerequisite Software
- Getting the Sources
- Environment Variable Setup
- Installing NPM Modules and Dart Packages
- Building
- Running Tests Locally
See the contribution guidelines if you'd like to contribute to Angular.
Before you can build and test Angular, you must install and configure the following products on your development machine:
-
Git and/or the GitHub app (for Mac or Windows); GitHub's Guide to Installing Git is a good source of information.
-
Node.js, (version
>=5.4.1 <6
) which is used to run a development web server, run tests, and generate distributable files. We also use Node's Package Manager,npm
(version>=3.5.3 <4.0
), which comes with Node. Depending on your system, you can install Node either from source or as a pre-packaged bundle. -
Optional: Dart (version
>=1.13.2 <2.0.0
), specifically the Dart SDK and Dartium (a version of Chromium with native support for Dart through the Dart VM). Visit Dart's Downloads page page for instructions. You can also download both stable and dev channel versions from the download archive. In that case, on Windows, Dart must be added to thePATH
(e.g.path-to-dart-sdk-folder\bin
) and a newDARTIUM_BIN
environment variable must be created, pointing to the executable (e.g.path-to-dartium-folder\chrome.exe
). -
Java Development Kit which is used to execute the selenium standalone server for e2e testing.
Fork and clone the Angular repository:
- Login to your GitHub account or create one by following the instructions given here.
- Fork the main Angular repository.
- Clone your fork of the Angular repository and define an
upstream
remote pointing back to the Angular repository that you forked in the first place.
# Clone your GitHub repository:
git clone [email protected]:<github username>/angular.git
# Go to the Angular directory:
cd angular
# Add the main Angular repository as an upstream remote to your repository:
git remote add upstream https://github.com/angular/angular.git
Define the environment variables listed below. These are mainly needed for the testing. The
notation shown here is for bash
; adapt as appropriate for
your favorite shell.
Examples given below of possible values for initializing the environment variables assume Mac OS
X and that you have installed the Dart Editor in the directory named by
DART_EDITOR_DIR=/Applications/dart
. This is only for illustrative purposes.
# DARTIUM_BIN: path to a Dartium browser executable; used by Karma to run Dart tests
export DARTIUM_BIN="$DART_EDITOR_DIR/chromium/Chromium.app/Contents/MacOS/Chromium"
Add the Dart SDK bin
directory to your path and/or define DART_SDK
(this is also detailed
here):
# DART_SDK: path to a Dart SDK directory
export DART_SDK="$DART_EDITOR_DIR/dart-sdk"
# Update PATH to include the Dart SDK bin directory
PATH+=":$DART_SDK/bin"
And specify where the pub’s dependencies are downloaded. By default, this directory is located under .pub_cache in your home directory (on Mac and Linux), or in AppData\Roaming\Pub\Cache (on Windows).
# PUB_CACHE: location of pub dependencies
export PUB_CACHE="/Users/<user>/.pub-cache"
Next, install the JavaScript modules and Dart packages needed to build and test Angular:
# Install Angular project dependencies (package.json)
npm install
Optional: In this document, we make use of project local npm
package scripts and binaries
(stored under ./node_modules/.bin
) by prefixing these command invocations with $(npm bin)
; in
particular gulp
and protractor
commands. If you prefer, you can drop this path prefix by either:
Option 1: globally installing these two packages as follows:
npm install -g gulp
(you might need to prefix this command withsudo
)npm install -g protractor
(you might need to prefix this command withsudo
)
Since global installs can become stale, and required versions can vary by project, we avoid their use in these instructions.
Option 2: defining a bash alias like alias nbin='PATH=$(npm bin):$PATH'
as detailed in this
Stackoverflow answer and used like this: e.g., nbin gulp build
.
To build Angular run:
./build.sh
- Results are put in the dist folder.
To run tests:
./test.sh node
./test.sh browser
./test.sh tools