【问题标题】:How to add a git repo in package.json file如何在 package.json 文件中添加 git repo
【发布时间】:2017-10-02 11:28:03
【问题描述】:

我有一个应用程序,在执行npm init 时,我没有在package.json 添加它的存储库。

现在我想在 package.json 文件中添加 repo,但找不到对我有用的解决方案。

另外,我发现存储库 url 的结尾是这样的.git,但我的 repo 地址就是这个https://github.com/sonyzach/usfm-validator

  1. 如何在 package.json 中添加我的 repo url?
  2. package.json中需要添加哪种格式?

【问题讨论】:

标签: node.js git github npm package.json


【解决方案1】:

您可以使用任何编辑器打开 package.json 文件,然后在主对象中添加以下内容

"repository": {
    "type": "git",
    "url": "https://github.com/sonyzach/usfm-validator.git"
},

我也认为你应该添加 .git 版本

【讨论】:

    【解决方案2】:

    只需运行以下命令:

    npm install --save https://github.com/sonyzach/usfm-validator

    纱线添加https://github.com/sonyzach/usfm-validator

    【讨论】:

      【解决方案3】:

      您可以在 package.json 文件中添加 dependencies 块,例如

        "dependencies": {
          "usfm-validator": "github.com/sonyzach/usfm-validator"
        }
      

      【讨论】:

        【解决方案4】:
        "repository": {
            "type": "git",
            "url": "git+ HTTP URL" // .git
        },
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-10-17
          • 2017-07-18
          • 2023-03-29
          • 2019-07-21
          • 1970-01-01
          • 2017-12-25
          • 1970-01-01
          • 2020-08-24
          相关资源
          最近更新 更多