LoginSignup
47
24

More than 3 years have passed since last update.

Githubまたはローカルのnpm のパッケージをinstallする方法

Last updated at Posted at 2019-07-03

はじめに

npmパッケージを作ろうとした時、公開前に手元のプロジェクトへインストールして動作を試す方法が分からなかったので調べてみました。

Githubからインストール

$ npm install account_name/repository_name

ブランチを指定する

$ npm install account_name/repository_name#master

フルパスでインストール

Github のページにある Clone or download でコピーしたURLを
npm install git+ の後に貼り付けるだけ

HTTPS

$ npm install git+https://account_name/repository_name.git

SSH

$ npm install git+ssh://git@github.com:account_name/repository_name.git

ローカルからインストール

ローカルにあるファイルパスを指定

$ npm install ../local_package_name

直接参照する訳ではなく、そのままコピーされてnode_modulesに入る。

最後に

npm installnpm i と省略できます。
Railsのgemを作るみたいに、ローカルから参照しながら作りたい。
(ローカルのbuildしたファイルを直接指定するとエラーが起きた。)

参考文献

47
24
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
47
24