Skip to content
9 changes: 9 additions & 0 deletions docs/dev-tools/backends/npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ For a scoped package, quote its full identifier, for example
`mise use 'npm:@biomejs/biome'`. The package's executable name can differ from its
registry name. mise installs CLI packages, not arbitrary libraries.

To install from a git repository instead of the registry, use a git URL or a
`github:`, `gitlab:` or `bitbucket:` shorthand. The version is the git ref
(a tag, branch or commit), and `latest` is the repository's default branch:

```sh
mise use 'npm:git+https://github.com/owner/repo'
mise use 'npm:github:owner/repo@v1.2.0'
```

If the project already declares Prettier in `package.json`, run that copy through
a package script to keep its plugins and version aligned with the project.

Expand Down
20 changes: 20 additions & 0 deletions e2e/backend/test_npm_git
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# npm: tools can be installed from a git repository instead of the registry.
repo="$PWD/gitpkg"
mkdir -p "$repo/bin"
cat >"$repo/package.json" <<'JSON'
{"name":"gitpkg","version":"1.0.0","bin":{"gitpkg":"bin/gitpkg.sh"}}
JSON
printf '#!/bin/sh\necho gitpkg-v1\n' >"$repo/bin/gitpkg.sh"
chmod +x "$repo/bin/gitpkg.sh"
git -C "$repo" init -q -b main
git -C "$repo" -c user.name=t -c user.email=t@t add -A
git -C "$repo" -c user.name=t -c user.email=t@t commit -q -m v1
git -C "$repo" tag v1

printf '#!/bin/sh\necho gitpkg-v2\n' >"$repo/bin/gitpkg.sh"
git -C "$repo" -c user.name=t -c user.email=t@t commit -q -am v2

assert_contains "mise x 'npm:git+file://$repo@latest' -- gitpkg" "gitpkg-v2"
assert_contains "mise x 'npm:git+file://$repo@v1' -- gitpkg" "gitpkg-v1"
Loading
Loading