如何在 package.json 文件中添加 git 存储库

How to add a git repo in package.json file

我有一个应用程序,在执行 npm init.

时没有在 package.json 中添加其存储库

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

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

  1. 如何在我的 package.json 中添加我的存储库 url?
  2. package.json需要添加什么格式?

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

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

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

只需 运行 下面的命令:

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

yarn add https://github.com/sonyzach/usfm-validator

"repository": {
    "type": "git",
    "url": "git+ HTTP URL" // .git
},

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

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