How to add a git repo in package.json file
Asked Answered
L

4

26

I have an app where I didn't add its repository in package.json while doing npm init.

Now I want to add repo in the package.json file, but couldn't find helpful solutions for me.

Also, I found repository url's ending like this .git but my repo address is simply this https://github.com/sonyzach/usfm-validator

  1. How can I add my repo url in my package.json?
  2. Which format need to add in package.json?
Later answered 4/5, 2017 at 10:24 Comment(1)
See Also: npm WARN package.json: No repository fieldDisbelief
R
44

You can just open the package.json file with any editor and add the following in the main object

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

also I think you should add the .git version

Relation answered 4/5, 2017 at 10:27 Comment(0)
T
12

Just run either below command:

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

or:

yarn add https://github.com/sonyzach/usfm-validator
Tubule answered 21/11, 2017 at 16:4 Comment(0)
A
1

you can add to dependencies block in your package.json file like

  "dependencies": {
    "usfm-validator": "github.com/sonyzach/usfm-validator"
  }
Alfonso answered 11/7, 2021 at 15:9 Comment(1)
I'm wondering how does it works with private repository?Halsey
P
1

npm pkg fix should fix your package.json issues automatically.

Add your github repo to your NPM package like this:

"repository": {
    "type": "git",
    "url": "git+https://github.com/your_username/repo_name.git"
}

From the docs: npm pkg fix will auto corrects common errors in your package.json. npm already does this during publish, which leads to subtle (mostly harmless) differences between the contents of your package.json file and the manifest that npm uses during installation.

Protean answered 5/6 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.