简体   繁体   English

为什么 npm 使用 git+ssh 安装与 https 不同?

[英]Why does npm install with git+ssh install differently than https?

What is the difference between installing a npm package via https and ssh?通过 https 和 Z1787D7646304C5D987ZCF46E 安装 npm package 有什么区别? My expectation is that the downloaded package would be the same but this is not the case.我的期望是下载的 package 将是相同的,但事实并非如此。 For example:例如:

// package.json
"dependencies": {
    "lodash": "^4.17.19"
    // vs
    "lodash": "git@github.com:lodash/lodash.git#semver:^4.17.19"
}

When I use the first option, the actual npm package gets installed.当我使用第一个选项时,安装了实际的 npm package。 When I install via the second option, I get only the files that are whitelisted from the repo but not the actual package itself.当我通过第二个选项安装时,我只得到从 repo 中列入白名单的文件,而不是实际的 package 本身。

I don't see a good explanation in the npm documentation.我在 npm 文档中没有看到很好的解释。 Why aren't these installing the same thing?为什么这些不安装相同的东西? Is there a way to install the actual package via ssh and not the commit itself?有没有办法通过 ssh 而不是提交本身安装实际的 package ?

Two ways of installing dependencies.安装依赖项的两种方式。

  1. From NPM repository itself (specify the version)来自 NPM 存储库本身(指定版本)
  2. From github (specify a branch OR commit and tag)从 github (指定一个分支或提交和标签)

It is advisable to publish to the registry the minified/compiled version of the library than the source unless it is necessary.除非有必要,否则建议将库的缩小/编译版本发布到注册表而不是源代码。 So, it is possible that what you get from the NPM is different than the source repository itself.因此,您从 NPM 获得的内容可能与源存储库本身不同。

It is really question of the "place" (npm or github) than the method (http or ssh)这真的是“地方”(npm 或 github)而不是方法(http 或 ssh)的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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