简体   繁体   中英

how to install specific branch of git repository using yarn?

I am able to install one GitHub package but not other using yarn. Please let me know what could be the issue here.

I can add https://github.com/fancyapps/fancybox#3.0 but not https://github.com/opentripplanner/otp-react-redux#result-post-processor

ravis-MacBook-Pro:gitprojects ******$ mkdir test
ravis-MacBook-Pro:gitprojects ******$ cd test
ravis-MacBook-Pro:test ***********$ yarn init
yarn init v1.6.0
question name (test): 
question version (1.0.0): 
question description: 
question entry point (index.js): 
question repository url: 
question author: 
question license (MIT): 
question private: 
success Saved package.json
✨  Done in 11.54s.

ravis-MacBook-Pro:test ******$ yarn add https://github.com/fancyapps/fancybox#3.0
yarn add v1.6.0
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > @fancyapps/fancybox@3.0.48" has unmet peer dependency "jquery@>=1.9.0".
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @fancyapps/fancybox@3.0.48
info All dependencies
└─ @fancyapps/fancybox@3.0.48
✨  Done in 1.35s.


ravis-MacBook-Pro:test *******$ yarn add https://github.com/opentripplanner/otp-react-redux#result-post-processor
yarn add v1.6.0
[1/4] 🔍  Resolving packages...
error Can't add "otp-react-redux": invalid package version undefined.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
ravis-MacBook-Pro:test *******$ 

You need use you git remote url and specify branch after hash(#).

yarn add https://github.com/opentripplanner/otp-react-redux.git#result-post-processor

installs a package from a remote git repository at specific git branch, git commit or git tag.

yarn add <git remote url>#<branch/commit/tag>

在此处输入图片说明

UPDATE

Please note that for Yarn 2+ you need to prefix the URL with package name:

yarn add otp-react-redux@https://github.com/opentripplanner/otp-react-redux#head=result-post-processor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM