Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(install): add instructions for git packages #1525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,60 @@ npm install @scope/package-name
npm install @scope/private-package-name
```

## Installing a package from Git

You can install a package directly from a Git repository using the following format:

```
npm install <git-remote-url>
```

For example, to install a package from a GitHub repository, run:

```
npm install git+https://github.com/user/repo.git
```

If you need a specific branch, tag, or commit, you can specify it after the `#` symbol:

```
npm install git+https://github.com/user/repo.git#branch-name
npm install git+https://github.com/user/repo.git#tag-name
npm install git+https://github.com/user/repo.git#commit-hash
```

## Installing a package from a GitHub shortcut

npm allows shorthand notation for installing from GitHub:

```
npm install user/repo
```

To install from a specific branch, tag, or commit:

```
npm install user/repo#branch-name
npm install user/repo#tag-name
npm install user/repo#commit-hash
```

## Installing a package from a Git subdirectory

Some repositories contain multiple packages in subdirectories. You can install a package from a specific subdirectory using:

```
npm install git+https://github.com/user/repo.git#commit-hash::path:path/to/subdirectory
npm install user/repo#commit-hash::path:path/to/subdirectory
```

For example:

```
npm install git+https://github.com/user/repo.git#main::path:packages/my-package
npm install user/repo#main::path:packages/my-package
```

## Testing package installation

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:
Expand Down