How to contribute to a NodeJS project uploaded on the Github account of an organization or developer using Git?
Tags: vscode, node, git, github
Published: 2020-12-24 11:31:20

# **STEPS**
   * Installation of the dependencies and IDE
   * Forking the Project
   * Cloning it on your local system 
   * Make changes
   * Committing changes to the Forked repository
   * Make a pull request


## 1. Installation of the dependencies
Dependencies that are to be installed for a NodeJs project are:

  1. [Git  ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1w315p0s2bm1ybhyeoqa.png)](https://git-scm.com/downloads)
  2. [NodeJs  ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/h4v13cemoousmrqgysfv.png)](https://nodejs.org/en/)
  3. [Visual Studio Code   ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/egbzn9izu9wtua9798j4.png)](https://code.visualstudio.com/Download)


  `Install the above dependencies as per your operating system.`



## 2. Forking the Project
`This step is not necessary for those wishing to directly contribute and does not want to just pile up the repositories in their account.Those people can skip to the 3rd step directly.`
Now suppose we have to contribute to the below repository, therefore we would need to fork this on our own repository first to edit it. Forking is just like making a copy of something. Therefore we click the Fork button available at the top right corner.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gvco8x5gtzm3sneoy1do.jpg)
 Then choose the account in which you want to fork it.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ri4b95j4ckn9vgjdbxw5.jpg)

**Well done!!!** You have successfully forked the repository.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qdngk00nn2uvkw2hrkkw.png)


## 3. Cloning it on your local system
Now lets start cloning it to our local system.
Head to the forked repository in your account and click on option 'Code' which would result in a dropdown menu. Select the notepad like icon next to the given link and the given link would be copied.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b2na7h5mi0swyiefyi0g.png)
Next, open your VS code and click the 'clone repository' option available next to the 'Open folder'.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vmmir9g1lpvnvht5z623.jpg)
After clicking it paste the link to the dialog box which appears and press the Enter key.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m4w8q9q3vffi87zz8ksj.png)
A pop-up window appears asking for the local storage of the repository. Choose the desired location and wait for the cloning process to finish.
**Great job!!!** You have successfully cloned the repository and it's showing in the sidebar.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0pqjyknfwiszhv5fr3dm.png)

## 4.Make Changes
Now we are good to make the changes in the project. So I would be showing you how to make this project a NodeJs project.
So follow these steps:
  * Click the Terminal option and choose New Terminal
  * Type `npm init`
  * After this fill in the asked details according to your preference or just keep pressing the Enter key.
  * Now you can see a package.json file created in the root directory.
  * After this you can install [Express.js](https://expressjs.com/)(NodeJs Framework) by typing `npm install express`. This would install the Express.js framework in your package file.

  For users who get an error like:
```
 npm is not recognized as an internal command...
```
can get it solved from [here.](https://stackoverflow.com/questions/20992723/npm-is-not-recognized-as-internal-or-external-command-operable-program-or-bat)

  For users who get an error like:
```
 git is not recognized as an internal command...
```
can get it solved from [here.](https://stackoverflow.com/questions/4492979/git-is-not-recognized-as-an-internal-or-external-command)
* After installing Express.Js, Make an index.js file in the root directory by clicking the new file option in the sidebar above package.json file.
* In the index.js file paste the code given [here.](https://expressjs.com/en/starter/hello-world.html)
* Now again head to the terminal window and type `node index.js`. You will see a output like this 
```
Example app listening at http://localhost:3000
```
* Open up your browser and open the port 3000 and congrats you have successfully set up an express app. Move back to the terminal in the VS code and press `ctrl+c` to close the server.


## 5.Committing changes to the Forked repository
Now what's left is just committing your work to the Github repository of yours. So let's begin:
  * Open the terminal and type 
   ```
   git add .
   ``` 
 This command would add all the changes made to the Local 
 Repository.
  * Next command is 
  ``` 
  git commit -m "Project Upload"
  ```
This command would commit your changes which are ready to be pushed to the main branch. You can change the message("Project Upload") according to your convenience.
  * In the end type
  ``` 
  git push -u origin main
  ```
This command would push all the changes to your Github account Repository. Refresh your Github Repository page and you would see the changes like this.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/a18coao14gp92n96atm3.png)

## 6. Making a pull request
Click on the pull requests option from above and click the `New Pull Request` option.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sr5cd6j4alh5tq3x96zj.png)
Click the `Create Pull Request` option and your works done.
Great Job!!! You have successfully made changes to the project and created a pull request. Now just relax and wait for your pull request to get merged by the organization.


So now you all know how to set up the environment for a NodeJs project and some of the git commands.


## Contact me: 
  * [Github](https://github.com/karankartikeya)
  * [LinkedIn](https://www.linkedin.com/in/karankartikeya/)
  * [Gmail](mailto:karankartikey72@gmail.com)