Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 620
zachi Avatar asked May 04 '17 10:05

zachi


People also ask

How do I add a Git repo to a npm package?

To npm install a public project that is hosted on Github, and not the NPM registry, add the Github repo to package. json dependencies using the username/repo#branch-name format. Run npm install and npm will download the project and save it into your /node_modules/ folder.

Can I manually add to package json?

You can add dependencies to a package. json file from the command line or by manually editing the package.

What is repository in package json?

The repository property of a package. json is an array that defines where the source code for the module lives. Typically, for open source projects, this would be a public GitHub repo, with the repository array noting that the type of version control is git , and the URL of the repo itself.


2 Answers

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

like image 158
Ivan Mladenov Avatar answered Sep 21 '22 23:09

Ivan Mladenov


Just run below command:

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

or

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

like image 30
Long Nguyen Avatar answered Sep 17 '22 23:09

Long Nguyen