首页 > 开发 > NodeJS > 正文

npm 如何引用github上的依赖包?

2017-09-08 17:11:19  来源:网友分享

开发配置是vuejs+element-ui,由于项目有些特殊功能,element-ui无法完全满足,我就fork了一份element-ui,并做了一些改动。
之后我在package.json 中引入我的自定义代码:

"dependencies": {    "element-ui": "git+https://github.com/xbb-web/element.git"}

然后执行npm install,发现node-modules/element-ui/下并没有包含项目中的全部代码,只有如下几个文件:src,package,LICENSE,package.json,README.md ,为什么?
请问我要如何把项目中的其他代码download下来?

解决方案

找到了解决方法,url后面跟上tag就好了。遇到问题还是要找官方文档,后续我会写一篇详细的文章来记录我此次的自定义element-ui经历吧。

Git urls can be of the form:

git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+http://user@hostname/project/...
git+https://user@hostname/project...
The commit-ish can be any tag, sha, or branch which can be supplied as an argument to git checkout. The default is master.

参考资料:https://docs.npmjs.com/how-np...