Skip to content

Commit 765b640

Browse files
authored
feat(install): add instructions for git packages
1 parent 6d5be44 commit 765b640

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

content/packages-and-modules/getting-packages-from-the-registry/downloading-and-installing-packages-locally.mdx

+54
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,60 @@ npm install @scope/package-name
4141
npm install @scope/private-package-name
4242
```
4343

44+
## Installing a package from Git
45+
46+
You can install a package directly from a Git repository using the following format:
47+
48+
```
49+
npm install <git-remote-url>
50+
```
51+
52+
For example, to install a package from a GitHub repository, run:
53+
54+
```
55+
npm install git+https://github.com/user/repo.git
56+
```
57+
58+
If you need a specific branch, tag, or commit, you can specify it after the `#` symbol:
59+
60+
```
61+
npm install git+https://github.com/user/repo.git#branch-name
62+
npm install git+https://github.com/user/repo.git#tag-name
63+
npm install git+https://github.com/user/repo.git#commit-hash
64+
```
65+
66+
## Installing a package from a GitHub shortcut
67+
68+
npm allows shorthand notation for installing from GitHub:
69+
70+
```
71+
npm install user/repo
72+
```
73+
74+
To install from a specific branch, tag, or commit:
75+
76+
```
77+
npm install user/repo#branch-name
78+
npm install user/repo#tag-name
79+
npm install user/repo#commit-hash
80+
```
81+
82+
## Installing a package from a Git subdirectory
83+
84+
Some repositories contain multiple packages in subdirectories. You can install a package from a specific subdirectory using:
85+
86+
```
87+
npm install git+https://github.com/user/repo.git#commit-hash::path:path/to/subdirectory
88+
npm install user/repo#commit-hash::path:path/to/subdirectory
89+
```
90+
91+
For example:
92+
93+
```
94+
npm install git+https://github.com/user/repo.git#main::path:packages/my-package
95+
npm install user/repo#main::path:packages/my-package
96+
```
97+
4498
## Testing package installation
4599

46100
To confirm that `npm install` worked correctly, in your module directory, check that a `node_modules` directory exists and that it contains a directory for the package(s) you installed:

0 commit comments

Comments
 (0)