diff --git a/docs/content/cli-commands/npm-install.md b/docs/content/cli-commands/npm-install.md index cfb96aeedd939..611cd54d1dbf3 100644 --- a/docs/content/cli-commands/npm-install.md +++ b/docs/content/cli-commands/npm-install.md @@ -16,6 +16,7 @@ npm install [<@scope>/] npm install [<@scope>/]@ npm install [<@scope>/]@ npm install [<@scope>/]@ +npm install @npm: npm install :/ npm install npm install @@ -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. @@ -78,13 +78,10 @@ after packing it up into a tarball (b). * `npm install `: - 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. @@ -94,8 +91,7 @@ after packing it up into a tarball (b). * `npm install `: - 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: @@ -113,12 +109,22 @@ after packing it up into a tarball (b). npm install sax +* `npm install @npm:`: + + 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`. @@ -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. `` is optional. The package will be downloaded from the registry associated with the specified scope. If no registry is associated with @@ -189,8 +194,7 @@ after packing it up into a tarball (b). * `npm install [<@scope>/]@`: - 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. @@ -216,8 +220,7 @@ after packing it up into a tarball (b). If `#` is provided, it will be used to clone exactly that commit. If the commit-ish has the format `#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 `#` or `#semver:` is + or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#` or `#semver:` is specified, then the default branch of the repository is used. If the repository makes use of submodules, those submodules will be cloned @@ -259,8 +262,7 @@ after packing it up into a tarball (b). If `#` is provided, it will be used to clone exactly that commit. If the commit-ish has the format `#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 `#` or `#semver:` is + or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#` or `#semver:` is specified, then `master` is used. As with regular git dependencies, `dependencies` and `devDependencies` will @@ -298,8 +300,7 @@ after packing it up into a tarball (b). If `#` is provided, it will be used to clone exactly that commit. If the commit-ish has the format `#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 `#` or `#semver:` is + or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#` or `#semver:` is specified, then `master` is used. As with regular git dependencies, `dependencies` and `devDependencies` will @@ -320,8 +321,7 @@ after packing it up into a tarball (b). If `#` is provided, it will be used to clone exactly that commit. If the commit-ish has the format `#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 `#` or `#semver:` is + or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#` or `#semver:` is specified, then `master` is used. As with regular git dependencies, `dependencies` and `devDependencies` will @@ -352,8 +352,7 @@ 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 @@ -361,7 +360,7 @@ 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). @@ -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. diff --git a/lib/install.js b/lib/install.js index a4cf2b186de51..528a3a0b59a75 100644 --- a/lib/install.js +++ b/lib/install.js @@ -26,6 +26,7 @@ install.usage = usage( '\nnpm install [<@scope>/]@' + '\nnpm install [<@scope>/]@' + '\nnpm install [<@scope>/]@' + + '\nnpm install @npm:' + '\nnpm install ' + '\nnpm install ' + '\nnpm install ' +