Install specific branch from github using Npm

2019-01-22 10:19发布

I would like to install bootstrap-loader from github in my project using npm

Currently they are maintaining two version of this project which are comaptible with webpack version 1 and 2.

I would like to install version 1. What npm command I should use to install this?

I tried using below one but it is not working.

npm install git://github.com/shakacode/bootstrap-loader.git[#v1] --Save 

4条回答
smile是对你的礼貌
2楼-- · 2019-01-22 10:50

Just do:

npm install username/repo#branchName --save

e.g.

npm i betimer/rtc-attach#master --save

"rtc-attach": "github:betimer/rtc-attach#master" (that's what package.json gets changed)

One thing I also want to mention: it's not a good idea to check in the package.json for the build server auto pull the change. Instead, put the npm i (first) command into the build command, and let server just install and replace the package.

查看更多
Juvenile、少年°
3楼-- · 2019-01-22 10:52

The Doc of the npm defines that only tag/version can be specified after repo_url.

Here is the Doc: https://docs.npmjs.com/cli/install

查看更多
迷人小祖宗
4楼-- · 2019-01-22 10:57

you can give git pattern as version, yarn and npm are clever enough to resolve from a git repo.

yarn add any-package@user-name/repo-name#branch-name

or for npm

npm install --save any-package@user-name/repo-name#branch-name
查看更多
该账号已被封号
5楼-- · 2019-01-22 10:59

There are extra square brackets in the command you tried.

To install the latest version from the v1 branch, you can use:

npm install git://github.com/shakacode/bootstrap-loader.git#v1 --save
查看更多
登录 后发表回答