Skip to content

Commit b150eae

Browse files
committedNov 18, 2019
docs: package aliases
PR-URL: #485 Credit: @claudiahdz Close: #485 Reviewed-by: @claudiahdz
1 parent 661d86c commit b150eae

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎docs/content/cli-commands/npm-install.md

+19
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ npm install [<@scope>/]<name>
1616
npm install [<@scope>/]<name>@<tag>
1717
npm install [<@scope>/]<name>@<version>
1818
npm install [<@scope>/]<name>@<version range>
19+
npm install <alias>@npm:<name>
1920
npm install <git-host>:<git-user>/<repo-name>
2021
npm install <git repo url>
2122
npm install <tarball file>
@@ -113,6 +114,24 @@ after packing it up into a tarball (b).
113114

114115
npm install sax
115116

117+
* `npm install <alias>@npm:<name>`:
118+
119+
Install a package under a custom alias. Allows multiple versions of
120+
a same-name package side-by-side, more convenient import names for
121+
packages with otherwise long ones and using git forks replacements
122+
or forked npm packages as replacements. Aliasing works only on your
123+
project and does not rename packages in transitive dependencies.
124+
Aliases should follow the naming conventions stated in
125+
[`validate-npm-package-name`](https://www.npmjs.com/package/validate-npm-package-name#naming-rules).
126+
127+
Examples:
128+
129+
npm install my-react@npm:react
130+
npm install jquery2@npm:jquery@2
131+
npm install jquery3@npm:jquery@3
132+
npm install npa@npm:npm-package-arg
133+
134+
116135
`npm install` saves any specified packages into `dependencies` by default.
117136
Additionally, you can control where and how they get saved with some
118137
additional flags:

‎lib/install.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ install.usage = usage(
2626
'\nnpm install [<@scope>/]<pkg>@<tag>' +
2727
'\nnpm install [<@scope>/]<pkg>@<version>' +
2828
'\nnpm install [<@scope>/]<pkg>@<version range>' +
29+
'\nnpm install <alias>@npm:<name>' +
2930
'\nnpm install <folder>' +
3031
'\nnpm install <tarball file>' +
3132
'\nnpm install <tarball url>' +

0 commit comments

Comments
 (0)
Please sign in to comment.