Install specific branch from github using Npm

别说谁变了你拦得住时间么 提交于 2019-12-17 10:30:46

问题


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 

回答1:


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



回答2:


Just do:

npm install username/repo#branchName --save

e.g. (my username is betimer)

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

// and what will appear in your package.json will be:
"rtc-attach": "github:betimer/rtc-attach#master"

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.




回答3:


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



回答4:


Another approach would be to add the following line to package.json dependencies:

"package-name": "user/repo#branch"

For example:

"dependencies": {
    ... other dependencies ...

    "react-native": "facebook/react-native#master"
}

And then do npm install or yarn install




回答5:


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



来源:https://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!