zachi
zachi

Reputation: 432

How to add a git repo in package.json file

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?

Upvotes: 28

Views: 41479

Answers (4)

AxelBlaze
AxelBlaze

Reputation: 336

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.

Upvotes: 2

Long Nguyen
Long Nguyen

Reputation: 10936

Just run either below command:

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

or:

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

Upvotes: 12

user889030
user889030

Reputation: 4754

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

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

Upvotes: 1

Ivan Mladenov
Ivan Mladenov

Reputation: 1847

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

Upvotes: 45

Related Questions