docs: clarify CommonJS and ES module examples in Node.js introduction - #121
docs: clarify CommonJS and ES module examples in Node.js introduction#121sumitjhacodes wants to merge 2 commits into
Conversation
Added explanation about running the HTTP server examples with CommonJS and ECMAScript modules. Signed-off-by: Sumit Jha <156579114+devlopersumit@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview The new text states that the CommonJS ( Reviewed by Cursor Bugbot for commit 8ce698c. Bugbot is set up for automated code reviews on this repo. Configure here. |
👋 Codeowner Review RequestThe 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! 🙏 |
| 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. | ||
|
|
There was a problem hiding this comment.
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>
Summary
This PR adds a brief explanation of the two server examples in the "Introduction to Node.js" page.
Changes
require()), while the second uses ECMAScript modules (import).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.