There are two fundamental components of the Pull Request process: one concrete
and technical, and one more process oriented.
The concrete and technical
component involves the specific details of setting up your local environment
so that you can make the actual changes.
This is where we will start.
Setting up your local environment
Step 1: Fork
Step 2: Branch
The Process of Making Changes
Step 3: Code
Step 4: Commit
Commit message guidelines
Step 5: Rebase
Step 6: Test
Step 7: Push
Step 8: Opening the Pull Request
Step 9: Discuss and Update
Approval and Request Changes Workflow
Step 10: Landing
Reviewing Pull Requests
Review a bit at a time
Be aware of the person behind the code
Respect the minimum wait time for comments
Abandoned or Stalled Pull Requests
Approving a change
Accept that there are different opinions about what belongs in Node.js
Performance is not everything
Continuous Integration Testing
Getting Approvals for your Pull Request
Waiting Until the Pull Request Gets Landed
Check Out the Collaborator Guide
Node.js has several bundled dependencies in the deps/ and the tools/ directories that are not part of the project proper. Changes to files in those directories should be sent to their respective projects. Do not send a patch to Node.js. We cannot accept such patches.
In case of doubt, open an issue in the issue tracker or contact one of the project Collaborators. Node.js has two IRC channels: #Node.js for general help and questions, and #Node-dev for development of Node.js core specifically.
To get started, you will need to have installed locally. Depending on your operating system, there are also a number of other dependencies required. These are detailed in the
Once you have and are sure you have all of the necessary dependencies, it's time to create a fork.
Fork the project on GitHub and clone your fork locally.
It is recommended to configure git so that it knows who you are:
Please make sure this local email is also added to your GitHub email list so that your commits will be properly associated with your account and you will be promoted to Contributor once your first commit is landed.
As a best practice to keep your development environment as organized as possible, create local branches to work within. These should also be created directly off of the master branch.
The vast majority of Pull Requests opened against the repository includes changes to one or more of the following:
- the C/C++ code contained in the `src` directory
- the documentation in `doc/api`
- tests within the `test` directory.
If you are modifying code, please be sure to run from time to time to ensure that the changes follow the Node.js code style guide.
Any documentation you write (including code comments and API documentation) should follow the. Code samples included in the API docs will also be checked when running (or on Windows).
For contributing C++ code, you may want to look at the
It is a recommended best practice to keep your changes as logically grouped as possible within individual commits. There is no limit to the number of commits any single Pull Request may have, and many contributors find it easier to review changes that are split across multiple commits.
Note that multiple commits often get squashed when they are landed (see the notes about).
A good commit message should describe what changed and why.
The first line should:
contain a short description of the change (preferably 50 characters or less, and no more than 72 characters)
be entirely in lowercase with the exception of proper nouns, acronyms, and the words that refer to code, like function/variable names
be prefixed with the name of the changed subsystem and start with an imperative verb. Check the output of to find out what subsystems your changes touch.
Keep the second line blank.
Wrap all other lines at 72 columns (except for long URLs).
If your patch fixes an open issue, you can add a reference to it at the end of the log. Use the: prefix and the full issue URL. For other references use:.
If your commit introduces a breaking change, it should contain an explanation about the reason of the breaking change, which situation would trigger the breaking change and what is the exact change.
Sample complete commit message:
subsystem: explain the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way, `git log` will show things
nicely even when it is indented.
If you are new to contributing to Node.js, please try to do your best at conforming to these guidelines, but do not worry if you get something wrong. One of the existing contributors will help get things situated and the contributor landing the Pull Request will ensure that everything follows the project guidelines.
See - A utility that ensures commits follow the commit formatting guidelines.
As a best practice, once you have committed your changes, it is a good idea
to use (not ) to synchronize your work with the main
This ensures that your working branch has the latest changes from master.
Bug fixes and features should always come with tests. A guide for writing tests in Node.js has been provided to make the process easier. Looking at other tests to see how they should be structured can also help.
The test directory within the repository is complex and it is often not clear where a new test file should go. When in doubt, add new tests to the directory and the right location will be sorted out later.
Before submitting your changes in a Pull Request, always run the full Node.js test suite. To run the tests (including code linting) on Unix / macOS:
And on Windows:
(See the for more details.)
Make sure the linter does not report any issues and that all tests pass. Please do not submit patches that fail either check.
If you are updating tests and just want to run a single test to check it:
You can execute the entire suite of tests for a given subsystem by providing the name of a subsystem:
If you want to check the other options, please refer to the help by using the option
You can usually run tests directly with node:
Remember to recompile with in between test runs if you change code in the or directories.
It's good practice to ensure any code you add or change is covered by tests. You can do so by running the test suite with coverage enabled:
Note that generating a test coverage report can take several minutes.
To collect coverage for a subset of tests you can set the and variables:
The above command executes tests for the subsystem and outputs the resulting coverage report.
Running tests with coverage will create and modify several directories and files. To clean up afterwards, run:
Once you are sure your commits are ready to go, with passing tests and linting, begin the process of opening a Pull Request by pushing your working branch to your fork on GitHub.
From within GitHub, opening a new Pull Request will present you with a template that should be filled out:
Thank you for your Pull Request. Please provide a description above and review
the requirements below.
Bug fixes and new features should include tests and possibly benchmarks.
Remove items that do not apply. For completed items, change to.
Please try to do your best at filling out the details, but feel free to skip parts if you're not sure what to put.
Once opened, Pull Requests are usually reviewed within a few days.
You will probably get feedback or requests for changes to your Pull Request. This is a big part of the submission process so don't be discouraged! Some contributors may sign off on the Pull Request right away, others may have more detailed comments or feedback. This is a necessary part of the process in order to evaluate whether the changes are correct and necessary.
To make changes to an existing Pull Request, make the changes to your local branch, add a new commit with those changes, and push those to your fork. GitHub will automatically update the Pull Request.
It is also frequently necessary to synchronize your Pull Request with other changes that have landed in by using:
Important: The command is one of the few ways to delete history in. Before you use it, make sure you understand the risks. If in doubt, you can always ask for guidance in the Pull Request or on IRC in the #node-dev channel.
If you happen to make a mistake in any of your commits, do not worry. You can amend the last commit (for example if you want to change the commit log).
There are a number of more advanced mechanisms for managing commits using that can be used, but are beyond the scope of this guide.
Feel free to post a comment in the Pull Request to ping reviewers if you are awaiting an answer on something. If you encounter words or acronyms that seem unfamiliar, refer to this glossary.
All Pull Requests require "sign off" in order to land. Whenever a contributor reviews a Pull Request they may find specific details that they would like to see changed or fixed. These may be as simple as fixing a typo, or may involve substantive changes to the code you have written. While such requests are intended to be helpful, they may come across as abrupt or unhelpful, especially requests to change things that do not include concrete suggestions on how to change them.
Try not to be discouraged. If you feel that a particular review is unfair, say so, or contact one of the other contributors in the project and seek their input. Often such comments are the result of the reviewer having only taken a short amount of time to review and are not ill-intended. Such issues can often be resolved with a bit of patience. That said, reviewers should be expected to be helpful in their feedback, and feedback that is simply vague, dismissive and unhelpful is likely safe to ignore.