Skip to content

docs: clarify CommonJS and ES module examples in Node.js introduction - #121

Open
sumitjhacodes wants to merge 2 commits into
nodejs:mainfrom
sumitjhacodes:patch-2
Open

docs: clarify CommonJS and ES module examples in Node.js introduction#121
sumitjhacodes wants to merge 2 commits into
nodejs:mainfrom
sumitjhacodes:patch-2

Conversation

@sumitjhacodes

Copy link
Copy Markdown

Summary

This PR adds a brief explanation of the two server examples in the "Introduction to Node.js" page.

Changes

  • Clarify that both examples create the same HTTP server.
  • Explain that the first example uses the CommonJS module system (require()), while the second uses ECMAScript modules (import).
  • Mention that the choice depends on the project's module system and configuration.

Motivation

While reading the introduction as a beginner, I noticed that the documentation presents both CommonJS and ES module examples without explaining why there are two versions. This small addition provides context for new users and helps them understand the purpose of each example without changing the existing content.

Added explanation about running the HTTP server examples with CommonJS and ECMAScript modules.

Signed-off-by: Sumit Jha <156579114+devlopersumit@users.noreply.github.com>
@sumitjhacodes
sumitjhacodes requested a review from a team as a code owner August 2, 2026 11:16
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodejs-learn Ready Ready Preview Aug 2, 2026 3:04pm

Request Review

@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Documentation-only wording in a getting-started guide; no runtime or build behavior changes.

Overview
Adds a short paragraph after the dual Hello World server snippets on Introduction to Node.js, so readers know why both blocks appear.

The new text states that the CommonJS (require()) and ESM (import) samples build the same server, links to the Node.js module docs, and notes that the choice follows the project’s module setup. No code or run instructions are changed.

Reviewed by Cursor Bugbot for commit 8ce698c. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/nodejs-website

Please review the changes when you have a chance. Thank you! 🙏

Comment on lines +59 to +60
Both examples create the same HTTP server. The first uses the CommonJS module system (`require()`), while the second uses ECMAScript modules (`import`). Which one you use depends on your project's module system and configuration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include links?

@sumitjhacodes sumitjhacodes Aug 2, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I'll update the paragraph to include links to the CommonJS and ECMAScript modules documentation.

Signed-off-by: Sumit Jha <156579114+sumitjhacodes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants