LoginSignup
55
40

More than 3 years have passed since last update.

npmのモジュールを自分でforkした版のやつに差し替える

Last updated at Posted at 2015-08-27

例として、npmの公式tupai.jsの代わりに自分専用のバージョンを使いたいとします。

Github上のモジュールを指定する

forkして作ったオレオレ版をGithubなどに置いておきます。
https://github.com/DQNEO/tupai.js/tree/dev

プロジェクトルートのpackage.jsonで、上記レポジトリとブランチを参照するように修正します。

package.json
{
    "name": "myproject",
    "dependencies": {
        "tupaijs" : "git+https://github.com/deyunanhai/tupai.js.git#master"
    }
}

これでnpm installすれば ./node_modules/の下にオレオレ版がインストールされます。

#masterのところは任意のブランチ名やタグ名、コミットハッシュ値を指定することができます。

ハマりポイント

https://github.com/... のような https URLは使えないようです。代わりに git+https:// と書きましょう。

ローカルのモジュールを指定する

公式マニュアルに詳しく書いてあるのでご参照ください。

55
40
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
55
40