versioned_docs_archived/version-3.x/pnpm-install-pkg.md
Installs a package and any packages that it depends on. By default, any new package is installed as a prod dependency.
| Command | Meaning |
|---|---|
pnpm i sax | npm package (save to dependencies) |
pnpm i -D sax | save to devDependencies |
pnpm i -O sax | save to optionalDependencies |
pnpm i -P sax | save to dependencies |
pnpm i sax@next | Specify tag next |
pnpm i [email protected] | Specify version 3.0.0 |
pnpm i sax@">=1 <2.0" | Specify version range |
pnpm i user/repo | GitHub |
pnpm i user/repo#master | GitHub |
pnpm i user/repo#semver:^2.0.0 | GitHub |
pnpm i github:user/repo | GitHub |
pnpm i gitlab:user/repo | GitHub |
pnpm i /path/to/repo | Absolute path |
pnpm i ./archive.tgz | Tarball |
pnpm i https://site.com/archive.tgz | Tarball via HTTP |
A package can be installed from different locations:
pnpm install package-name will install the latest version
of package-name from the npm registry.
You may also install packages by:
pnpm install express@nightlypnpm install [email protected]pnpm install express@2 react@">=0.1.0 <0.2.0"There are two ways to install from the local file system:
.tar, .tar.gz, or .tgz)Examples:
pnpm install ./package.tgz
pnpm install ./some-directory
When you install from a directory, a symlink will be created in the
current project's node_modules, so it is the same as running
pnpm link.
The argument must start with "http://" or "https://".
Example:
pnpm install https://github.com/indexzero/forever/tarball/v0.5.6
npm install <git remote url>
Installs the package from the hosted Git provider, cloning it with Git.
You may install from Git by:
pnpm install kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678pnpm install kevva/is-positive#masterpnpm install kevva/is-positive#semver:^2.0.0This will install one or more packages in your dependencies.
Using --save-dev or -D will install one or more packages in your devDependencies.
Using --save-optional or -O will install one or more packages in your optionalDependencies.
Saved dependencies will be configured with an exact version rather than using pnpm's default semver range operator.
Added in: v3.2.0
Using --save-peer will add one or more packages to peerDependencies and install them as dev dependencies.