Installing Packages

To install named packages, use the pak install PACKAGES ... command and name the packages to install. Multiple packages can be installed on one command line.

You first need to run pak init if you do not have a pak.json in the current directory. For example:

$ pak init $ pak install jquery bootstrap [Install] jquery 2.1.3 [Install] bootstrap 3.3.2

Alternatively, you can use the --init option to initialize the directory by creating a pak.json file if one does not already exist.

$ pak -i install jquery bootstrap [Install] jquery 2.1.3 [Install] bootstrap 3.3.2

The pak install command will download the packages, save them in the per-user global package cache and install the package under the paks directory. If invoked with the --write option, Pak will record which packages are required by adding an entry to a pak.json.

$ pak --write install jquery bootstrap

The updated pak.json will look like this subset:

{ "name": "my "version": "1.0.0", "dependencies": { "bootstrap": "^3.3", "jquery": "^2.1" }, "import": true, "mode": "debug" }

The dependencies property will document the required packages and their versions. You can modify the version string for packages to specify what range of versions your application can accept. See Pak Versions for more details.

In the previous example, Bootstrap internally specifies jQuery as a dependency, so we could have installed just Bootstrap and it would have automatically downloaded and installed jquery — as it is required by Bootstrap. For example:

$ pak --write install bootstrap [Install] jquery 2.1.3 [Install] bootstrap 3.3.2

Without requesting jQuery, Pak knew to install it because it was listed in the Bootstrap dependencies.

Installation Process

When Pak installs a package, it follows the following process:

  1. Lookup the specified pak name in various catalogs and determine the repository location for the pak.
  2. Download the pak from the repository.
  3. Save the pak contents in to the Pak global cache. This is typically at ~/.pak/PACKAGE.
  4. Install the pak contents locally in the paks/PACKAGE directory.
  5. Export selected contents to the lib/PACKAGE directory for use.

Package Endpoints

When installing packages, the package name may be a simple name, or it may be a more complex endpoint that describes where to locate the package. The complete syntax is:

pak install ENDPOINTS ...

Where an ENDPOINT can be the name of a package published in the Pak catalog, NPM or bower catalog, a GitHub repository endpoint, a GitHub account/repository or a path to a local package directory. For example:

pak install jquery pak install embedthis/exp-js pak install https://github.com/embedthis/exp-js.git pak install git@github.com:embedthis/jquery pak install ./my-source/graphics

GitHub Endpoints

A catalog search is not required if the endpoint is a resolved Git repository endpoint. Three forms are supported:

The account/repository form is a short-cut for https://github.com/account/repository.git.

An endpoint may optionally have a #version suffix that nominates a specific version to install. Otherwise the most recent, stable version will be selected. For example:

pak install jquery#2.1.3

Forced Installation

To force a package to be installed regardless of whether it is already installed or not.

pak -f install PACKAGE ...

Installing and Upgrading Packages

To install all the packages required by an application as specified in pak.json:

pak install

To reinstall all the application's packages.

pak -f install

To upgrade all the packages required by an application as specified in pak.json:

pak upgrade

This will upgrade the application using the latest versions of packages. This will download newer package versions and update the cache if required. Use --noupdate to upgrade only from the local cache.

To update the package cache with the latest available version of a package:

pak update NAME

© Embedthis Software. All rights reserved.