【问题标题】:Private bitbucket repository in package.json with versionpackage.json 中带有版本的私有 bitbucket 存储库
【发布时间】:2017-10-09 07:55:32
【问题描述】:

我正在尝试在我的 package.json 中包含一个私有 BitBucket 存储库,但我也想将版本作为普通模块进行管理。 目前我正在使用这个

"package-name": "git+https://<user>:<password>@<url-repository>.git"

我已经试过了,但是没用。

"package-name": "git+https://<user>:<password>@<url-repository>.git#v1.0"

有什么想法吗?

【问题讨论】:

    标签: bitbucket npm-install node-modules package.json


    【解决方案1】:

    你必须在模块 repo 中标记你想要安装的版本。 repo url 可以在模块的package.json 文件中找到,例如

    "repository": {
        "type": "git",
        "url": "git+https://github.com/repo-owner-name/my-module.git" // <-- This line!
    },
    

    当您向版本添加标签(例如git tag -a 0.0.1 -m "auto release")后,可以使用以下方式安装它:

    "my-module": "git+https://bitbucket.org/repo-owner-name/my-module.git#0.0.1"
    

    【讨论】:

      【解决方案2】:
      1. 登录您的 bitbucket 帐户并在用户设置下添加应用密码:

      2. 将包依赖项添加到您的package.json 为:

      "dependencies": {
      "my-module": "git+https://Xaqron:pwd@bitbucket.org/Xaqron/my-module.git#*"
      }
      

      Xaqron 替换为您自己的用户名,将pwd 替换为第一步中的应用密码。

      要安装特定版本,请将 #v.v.v(即#1.0.0)添加到依赖 URL 的末尾。

      【讨论】:

      • 那个版本是分支实际上只是为了清楚
      • 注意:您必须使用您的主 Bitbucket 用户名,而不是您在第一步中创建的应用密码的“标签”。
      • @AdamGerthel 您可以通过在 URL 末尾添加 #semver:whatever 来使用版本范围。示例:my-module.git#semver:^1.5.2.
      • 但这会将我的 bitbucket 密码留在 package.json 中,我很可能会使用 git 进行跟踪。不是一个非常安全的解决方案。
      • @wolfson109 改用git+ssh
      【解决方案3】:

      我目前正在使用它并且它有效:

      {
        "dependencies": {
          "package-name": "git+ssh://git@<url-repository>.git#v0.1.0"
        }
      }
      

      我正在使用npm 版本4.1.2 和自托管bitbucket 版本4.14.6

      【讨论】:

        猜你喜欢
        • 2018-03-19
        • 2013-08-10
        • 2018-03-09
        • 2018-01-06
        • 2017-10-19
        • 2017-01-04
        • 1970-01-01
        • 2017-02-25
        • 2019-12-26
        相关资源
        最近更新 更多