0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitHubのPrivate Repositoryで作ったものをpackage.jsonのdependenciesに登録する方法

Posted at

これは何

  • 公開するレベルではない自分で作ったライブラリを他のリポジトリで書いているコードのdependenciesに指定する方法をまとめた記事です
    • 過去に自分で書いたコードを掘り返してはコピペしているので記事にしてみました

やり方

通常のnpm installなどで入れたものは以下のように記載されています。

{
  "dependencies": {
    "next": "11.1.2",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
}

例えば

  • my-own-personal-libraryという名前のパッケージとして
  • ssh接続で
  • https://github.com/xrxoxcxox/very-small-libraryというリポジトリ

でインストールするとしたら以下のようになります。

  {
    "dependencies": {
      "next": "11.1.2",
+     "my-own-personal-library": "git+ssh://git@github.com/xrxoxcxox/very-small-library",
      "react": "17.0.2",
      "react-dom": "17.0.2"
    },
  }

git+ssh以外の書き方でいうとgit, git+ssh, git+http, git+https, git+fileが取れます。

また、試しにブランチを切って書いた内容を試してみたい場合は以下のように変更します。

  {
    "dependencies": {
      "next": "11.1.2",
-     "my-own-personal-library": "git+ssh://git@github.com/xrxoxcxox/very-small-library",
+     "my-own-personal-library": "git+ssh://git@github.com/xrxoxcxox/very-small-library#branch-name",
      "react": "17.0.2",
      "react-dom": "17.0.2"
    },
  }

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?