How to specify npm dependency as github subfolder url?

回眸只為那壹抹淺笑 提交于 2021-01-02 22:48:29

问题


My git repository:

README.md
packages
  common
    package.json
  main
    package.json

How to specify common dependency in main package.json as github subfolder url?

This does not work "common": "git://github.com/<user>/<project>/packages/common.git"


回答1:


It looks like this is not supported by NPM, and the NPM team appears to have no interest in supporting this functionality.

https://github.com/npm/npm/issues/2974




回答2:


What you are looking for is git submodules. in short you are telling get to look for this folder in the following repo.

to do this, execute the following command:

git submodule add git://github.com/<user>/<project>/packages/common.git packages/common

notice that when cloning the repo you need to recursively clone it to be able to download the submodules:

git clone --recursive <your-git-url>


来源:https://stackoverflow.com/questions/39679799/how-to-specify-npm-dependency-as-github-subfolder-url

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