Git url 的格式为:
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
<protocol> 是 git、git+ssh、git+http、git+https 或 git+file 之一。
如果提供了 #<commit-ish>,它将用于准确克隆该提交。如果 commit-ish 的格式为 #semver:<semver>,<semver> 可以是任何有效的 semver 范围或确切版本,npm 将在远程存储库中查找与该范围匹配的任何标记或引用,就像它查找注册表依赖项一样。如果既没有指定 #<commit-ish> 也没有指定 #semver:<semver>,则使用默认分支。
例子:
git+ssh://git@github.com:npm/cli.git#v1.0.27
git+ssh://git@github.com:npm/cli#semver:^5.0
git+https://isaacs@github.com/npm/cli.git
git://github.com/npm/cli.git#v1.0.27
从 git 存储库安装时,package.json 中某些字段的存在将导致 npm 认为它需要执行构建。为此,您的存储库将被克隆到一个临时目录中,安装其所有 deps,运行相关脚本,并打包并安装生成的目录。
如果您的 git 依赖项使用 workspaces,或者如果存在以下任何脚本,则会发生此流程:
buildprepareprepackpreinstallinstallpostinstall如果您的 git 存储库包含预构建的工件,您可能希望确保没有定义上述脚本,否则将为每次安装重新构建您的依赖项。