Skip to content

Commit

Permalink
docs: add package alias info
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiahdz committed Nov 15, 2019
1 parent 454c7dd commit 4613d60
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
53 changes: 26 additions & 27 deletions docs/content/cli-commands/npm-install.md
Expand Up @@ -16,6 +16,7 @@ npm install [<@scope>/]<name>
npm install [<@scope>/]<name>@<tag>
npm install [<@scope>/]<name>@<version>
npm install [<@scope>/]<name>@<version range>
npm install <alias>@npm:<name>
npm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
npm install <tarball file>
Expand Down Expand Up @@ -63,8 +64,7 @@ after packing it up into a tarball (b).
With the `--production` flag (or when the `NODE_ENV` environment variable
is set to `production`), npm will not install modules listed in
`devDependencies`. To install all modules listed in both `dependencies`
and `devDependencies` when `NODE_ENV` environment variable is set to `production`,
you can use `--production=false`.
and `devDependencies` when `NODE_ENV` environment variable is set to `production`, you can use `--production=false`.

> NOTE: The `--production` flag has no particular meaning when adding a
dependency to a project.
Expand All @@ -78,13 +78,10 @@ after packing it up into a tarball (b).

* `npm install <tarball file>`:

Install a package that is sitting on the filesystem. Note: if you just want
to link a dev directory into your npm root, you can do this more easily by
using `npm link`.
Install a package that is sitting on the filesystem. Note: if you just want to link a dev directory into your npm root, you can do this more easily by using `npm link`.

Tarball requirements:
* The filename *must* use `.tar`, `.tar.gz`, or `.tgz` as
the extension.
* The filename *must* use `.tar`, `.tar.gz`, or `.tgz` as the extension.
* The package contents should reside in a subfolder inside the tarball (usually it is called `package/`). npm strips one directory layer when installing the package (an equivalent of `tar x --strip-components=1` is run).
* The package must contain a `package.json` file with `name` and `version` properties.

Expand All @@ -94,8 +91,7 @@ after packing it up into a tarball (b).

* `npm install <tarball url>`:

Fetch the tarball url, and then install it. In order to distinguish between
this and other options, the argument must start with "http://" or "https://"
Fetch the tarball url, and then install it. In order to distinguish between this and other options, the argument must start with "http://" or "https://"

Example:

Expand All @@ -113,12 +109,22 @@ after packing it up into a tarball (b).

npm install sax

* `npm install <alias>@npm:<name>`:

Install a package under a custom alias. Allows multiple versions of a same-name package side-by-side, more convenient import names for packages with otherwise long ones and using git forks replacements or forked npm packages as replacements. Aliasing works only on your project and does not rename packages in transitive dependencies. Aliases should follow the naming conventions stated in [`validate-npm-package-name`](https://www.npmjs.com/package/validate-npm-package-name#naming-rules).

Examples:

npm install my-react@npm:react
npm install jquery2@npm:jquery@2
npm install jquery3@npm:jquery@3
npm install npa@npm:npm-package-arg

`npm install` saves any specified packages into `dependencies` by default.
Additionally, you can control where and how they get saved with some
additional flags:

* `-P, --save-prod`: Package will appear in your `dependencies`. This is the
default unless `-D` or `-O` are present.
* `-P, --save-prod`: Package will appear in your `dependencies`. This is the default unless `-D` or `-O` are present.

* `-D, --save-dev`: Package will appear in your `devDependencies`.

Expand All @@ -135,8 +141,7 @@ after packing it up into a tarball (b).

* `-B, --save-bundle`: Saved dependencies will also be added to your `bundleDependencies` list.

Further, if you have an `npm-shrinkwrap.json` or `package-lock.json` then it
will be updated as well.
Further, if you have an `npm-shrinkwrap.json` or `package-lock.json` then it will be updated as well.

`<scope>` is optional. The package will be downloaded from the registry
associated with the specified scope. If no registry is associated with
Expand Down Expand Up @@ -189,8 +194,7 @@ after packing it up into a tarball (b).

* `npm install [<@scope>/]<name>@<version range>`:

Install a version of the package matching the specified version range. This
will follow the same rules for resolving dependencies described in [`package.json`](/configuring-npm/package-json).
Install a version of the package matching the specified version range. This will follow the same rules for resolving dependencies described in [`package.json`](/configuring-npm/package-json).

Note that most version ranges must be put in quotes so that your shell will
treat it as a single argument.
Expand All @@ -216,8 +220,7 @@ after packing it up into a tarball (b).
If `#<commit-ish>` is provided, it will be used to clone exactly that
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
be any valid semver range or exact version, and npm will look for any tags
or refs matching that range in the remote repository, much as it would for a
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
specified, then the default branch of the repository is used.

If the repository makes use of submodules, those submodules will be cloned
Expand Down Expand Up @@ -259,8 +262,7 @@ after packing it up into a tarball (b).
If `#<commit-ish>` is provided, it will be used to clone exactly that
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
be any valid semver range or exact version, and npm will look for any tags
or refs matching that range in the remote repository, much as it would for a
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
specified, then `master` is used.
As with regular git dependencies, `dependencies` and `devDependencies` will
Expand Down Expand Up @@ -298,8 +300,7 @@ after packing it up into a tarball (b).
If `#<commit-ish>` is provided, it will be used to clone exactly that
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
be any valid semver range or exact version, and npm will look for any tags
or refs matching that range in the remote repository, much as it would for a
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
specified, then `master` is used.
As with regular git dependencies, `dependencies` and `devDependencies` will
Expand All @@ -320,8 +321,7 @@ after packing it up into a tarball (b).
If `#<commit-ish>` is provided, it will be used to clone exactly that
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
be any valid semver range or exact version, and npm will look for any tags
or refs matching that range in the remote repository, much as it would for a
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
specified, then `master` is used.
As with regular git dependencies, `dependencies` and `devDependencies` will
Expand Down Expand Up @@ -352,16 +352,15 @@ have done without actually installing anything.
The `--package-lock-only` argument will only update the `package-lock.json`,
instead of checking `node_modules` and downloading dependencies.
The `-f` or `--force` argument will force npm to fetch remote resources even if a
local copy exists on disk.
The `-f` or `--force` argument will force npm to fetch remote resources even if a local copy exists on disk.
```bash
npm install sax --force
```
The `--no-fund` argument will hide the message displayed at the end of each
install that acknowledges the number of dependencies looking for funding.
See `npm-fund(1)`
See `[npm fund]`(/cli-commands/npm-fund).
The `-g` or `--global` argument will cause npm to install the package globally
rather than locally. See [folders](/configuring-npm/folders).
Expand Down Expand Up @@ -402,7 +401,7 @@ The `--only={prod[uction]|dev[elopment]}` argument will cause either only
`devDependencies` or only non-`devDependencies` to be installed regardless of the `NODE_ENV`.
The `--no-audit` argument can be used to disable sending of audit reports to
the configured registries. See [`npm-audit`](npm-audit) for details on what is sent.
the configured registries. See [`npm audit`](/cli-commands/npm-audit) for details on what is sent.
See [`config`](/using-npm/config). Many of the configuration params have some
effect on installation, since that's most of what npm does.
Expand Down
1 change: 1 addition & 0 deletions lib/install.js
Expand Up @@ -26,6 +26,7 @@ install.usage = usage(
'\nnpm install [<@scope>/]<pkg>@<tag>' +
'\nnpm install [<@scope>/]<pkg>@<version>' +
'\nnpm install [<@scope>/]<pkg>@<version range>' +
'\nnpm install <alias>@npm:<name>' +
'\nnpm install <folder>' +
'\nnpm install <tarball file>' +
'\nnpm install <tarball url>' +
Expand Down

0 comments on commit 4613d60

Please sign in to comment.