Overview
Pull Requests are the way concrete changes are made to the code, documentation, dependencies, and tools contained in thenodejs/node repository.
Dependencies
Node.js has several bundled dependencies in thedeps/ and tools/ directories that are not part of the project proper. Changes to files in those directories should be sent to their respective projects.
For more information, see the maintaining dependencies document.
Getting Help
If you’re unsure about dependencies or need help:- Open an issue in the issue tracker
- Contact one of the project collaborators
- Join the OpenJS Foundation Slack:
- #nodejs - General help and discussions
- #nodejs-core - Core development
- Join Slack
Setting Up Your Local Environment
Prerequisites
To get started, you will need:gitinstalled locally- Build dependencies for your operating system (see Building guide)
- Optional: IDE-specific settings from IDE configs
Step 1: Fork
Fork the project on GitHub and clone your fork locally.git so that it knows who you are:
Step 2: Branch
As a best practice to keep your development environment as organized as possible, create local branches to work within. These should be created directly off of the upstream default branch.The Process of Making Changes
Step 3: Code
Pull requests in Node.js typically involve changes to one or more of:- C/C++ code in the
srcdirectory - JavaScript code in the
libdirectory - Documentation in
doc/api - Tests in the
testdirectory
Code Quality
If you are modifying code, run the linter:Documentation Style
Any documentation you write (including code comments and API documentation) should follow the Style Guide. When adding to or deprecating an API, useREPLACEME for the version number in the documentation YAML:
C++ Code
For contributing C++ code, review:- C++ Style Guide
- README of
src/- Overview of Node.js C++ internals
Step 4: Commit
It is a 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.Multiple commits often get squashed when they are landed. See the notes about commit squashing.
Commit Message Guidelines
A good commit message should describe what changed and why. First line should:- Contain a short description (preferably 50 characters or less, no more than 72 characters)
- Be entirely in lowercase except for proper nouns, acronyms, and code references
- Be prefixed with the subsystem name and start with an imperative verb
- Keep blank
- Wrap at 72 columns (except for long URLs)
- Provide detailed explanation of changes
semver-major), include:
- Reason for the breaking change
- Situation that triggers it
- Exact nature of the change
Step 5: Rebase
As a best practice, once you have committed your changes, usegit rebase (not git merge) to synchronize your work with the main repository.
nodejs/node.
Step 6: Test
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. Run tests on Unix / macOS:For some configurations, running all tests might take a long time (an hour or more). To run a subset of the test suite, see the running tests section of the Building guide.
Step 7: Push
Once you are sure your commits are ready to go, with passing tests and linting, push your working branch to your fork on GitHub.Step 8: Opening the Pull Request
From within GitHub, opening a new pull request will present you with a pull request template. Please try to do your best at filling out the details. Once opened, pull requests are usually reviewed within a few days.Step 9: Discuss and Update
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.Making Updates
To make changes to an existing pull request:Handling Conflicts
If a git conflict arises, synchronize your branch with upstream:Approval and Request Changes Workflow
All pull requests require “sign off” in order to land. 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.Step 10: Landing
In order to land, a pull request needs to be:- Reviewed and approved by at least two Node.js Collaborators (one collaborator approval is enough if the pull request has been open for more than 7 days)
- Pass a CI (Continuous Integration) test run
- Have no objections from other contributors
GitHub might show the pull request as
Closed at this point, but don’t worry. If you look at the branch you raised your pull request against, you should see a commit with your name on it. Congratulations and thanks for your contribution!Reviewing Pull Requests
Review Philosophy
All Node.js contributors who choose to review and provide feedback on Pull Requests have a responsibility to both the project and the individual making the contribution. Reviews and feedback must be:- Helpful: Provide actionable suggestions
- Insightful: Share expertise and knowledge
- Constructive: Focused on improving the contribution
- Respectful: Follow the Code of Conduct
Review Goals
When reviewing a pull request, the primary goals are:- For the codebase to improve
- For the person submitting the request to succeed
Even if a pull request does not land, the submitters should come away from the experience feeling like their effort was not wasted or unappreciated. Every pull request from a new contributor is an opportunity to grow the community.
Review a Bit at a Time
Do not overwhelm new contributors. Focus first on the most significant aspects:- Does this change make sense for Node.js?
- Does this change make Node.js better, even if only incrementally?
- Are there clear bugs or larger scale issues that need attending to?
- Is the commit message readable and correct?
Be Aware of the Person Behind the Code
Be aware that how you communicate requests and reviews in your feedback can have a significant impact on the success of the pull request. The goal is not just having good code - it’s also ensuring contributors want to continue participating in the project.Respect the Minimum Wait Time
There is a minimum waiting time which we try to respect for non-trivial changes:- Non-trivial changes: Must be left open for at least 48 hours
- Trivial changes: Limited to small formatting changes or fixes to documentation, may be landed within the minimum 48 hour window
Abandoned or Stalled Pull Requests
If a pull request appears to be abandoned or stalled:- Check with the contributor to see if they intend to continue
- Ask if they would mind if you took it over
- Give the original contributor credit in the commit log
If a pull request has been inactive for more than six months, add the
stalled label. This triggers automation that adds a comment explaining the pull request may be closed for inactivity.Approving a Change
Any Node.js core collaborator is authorized to approve any other contributor’s work. Collaborators are not permitted to approve their own pull requests. Collaborators indicate approval by:- Using GitHub’s Approval Workflow (preferred)
- Leaving an
LGTM(“Looks Good To Me”) comment
Continuous Integration Testing
All pull requests that contain changes to code must be run through continuous integration (CI) testing at https://ci.nodejs.org/. Only Node.js core collaborators and triagers can start a CI testing run.Notes
Commit Squashing
In most cases, do not squash commits that you add to your pull request during the review process. When the commits in your pull request land, they may be squashed into one commit per logical change. Metadata will be added to the commit message including:- Links to the pull request
- Links to relevant issues
- Names of the reviewers
Getting Approvals for Your Pull Request
A pull request is approved either by saying LGTM (“Looks Good To Me”) or by using GitHub’s Approve button.Waiting Until the Pull Request Gets Landed
A pull request needs to stay open for at least 48 hours from when it is submitted, even after it gets approved and passes the CI. This is to make sure that everyone has a chance to weigh in.Subsystems
When writing commit messages, prefix with the appropriate subsystem:lib/*.js(assert,buffer, etc.)builddoclib / srctesttools