DEV Community

Cover image for How to contribute to a NodeJS project uploaded on the Github account of an organization or developer using Git?
karan kartikeya
karan kartikeya

Posted on

How to contribute to a NodeJS project uploaded on the Github account of an organization or developer using Git?

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. Alt Text
  2. Alt Text
  3. Alt Text

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
Then choose the account in which you want to fork it.
Alt Text

Well done!!! You have successfully forked the repository.
Alt Text

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
Next, open your VS code and click the 'clone repository' option available next to the 'Open folder'.
Alt Text
After clicking it paste the link to the dialog box which appears and press the Enter key.
Alt Text
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

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(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...
Enter fullscreen mode Exit fullscreen mode

can get it solved from here.

For users who get an error like:

 git is not recognized as an internal command...
Enter fullscreen mode Exit fullscreen mode

can get it solved from here.

  • 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.
  • 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
Enter fullscreen mode Exit fullscreen mode
  • 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 .
Enter fullscreen mode Exit fullscreen mode

This command would add all the changes made to the Local
Repository.

  • Next command is
  git commit -m "Project Upload"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

6. Making a pull request

Click on the pull requests option from above and click the New Pull Request option.
Alt Text
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:

Top comments (0)