<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Creating First NodeJS Server]]></title><description><![CDATA[Creating First NodeJS Server]]></description><link>https://nodejs-essentials.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 09:18:54 GMT</lastBuildDate><atom:link href="https://nodejs-essentials.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Creating my First NodeJS Server]]></title><description><![CDATA[JavaScript was the language of the web browser. It made our websites interactive, dynamic, and user-friendly. But its role was clear: it handled the front-end, or client-side. For the back-end—the server, database, and core application logic—develope...]]></description><link>https://nodejs-essentials.hashnode.dev/creating-my-first-nodejs-server</link><guid isPermaLink="true">https://nodejs-essentials.hashnode.dev/creating-my-first-nodejs-server</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Deepansh Vishwakarma]]></dc:creator><pubDate>Sun, 31 Aug 2025 17:23:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756579919634/ff877867-79f9-4563-881e-212c8a9eeb6b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>JavaScript was the language of the web browser. It made our websites interactive, dynamic, and user-friendly. But its role was clear: it handled the front-end, or client-side. For the back-end—the server, database, and core application logic—developers turned to other languages like PHP, Java, or Python.</p>
<p>Node.js is a technology that completely changed the game. Node.js is not a new language or a framework. <strong>It is a runtime environment that allows you to run JavaScript code on the server</strong>. It took JavaScript from being a browser-only tool to a powerful, general-purpose language capable of building the entire back-end of a web application.</p>
<h2 id="heading-setting-up-your-first-nodejs-app">Setting Up Your First Node.js App</h2>
<p>Ready to get your hands dirty? Let's build a simple "Hello World" web server.</p>
<h3 id="heading-step-1-install-nodejs">Step 1: Install Node.js</h3>
<p>First, you need to install Node.js on your computer.</p>
<ol>
<li><p>Go to the official Node.js website: <a target="_blank" href="https://nodejs.org/">https://nodejs.org/</a></p>
</li>
<li><p>Download the <strong>LTS (Long Term Support)</strong> version for your operating system (Windows, macOS, or Linux). LTS is recommended for most users because it’s the most stable.</p>
</li>
<li><p>Run the installer and follow the on-screen instructions.</p>
</li>
</ol>
<p>To verify the installation, open your terminal or command prompt and run these two commands:</p>
<p>Bash</p>
<pre><code class="lang-javascript">node -v
npm -v
</code></pre>
<p>If the installation was successful, you'll see the version numbers for Node.js and npm (Node Package Manager, which is installed automatically with Node.js).</p>
<h3 id="heading-step-2-write-your-hello-world-server">Step 2: Write Your "Hello World" Server</h3>
<p>Now, let's write the code.</p>
<ol>
<li><p>Create a new folder for your project (e.g., <code>my-node-app</code>).</p>
</li>
<li><p>Inside that folder, create a new file named <code>app.js</code>.</p>
</li>
<li><p>Open <code>app.js</code> in your favorite code editor and add the following code:</p>
<pre><code class="lang-javascript"> <span class="hljs-keyword">const</span> http = <span class="hljs-built_in">require</span>(<span class="hljs-string">'http'</span>);

 <span class="hljs-keyword">const</span> hostname = <span class="hljs-string">'127.0.0.1'</span>;
 <span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

 <span class="hljs-comment">// Create the server</span>
 <span class="hljs-keyword">const</span> server = http.createServer(<span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
   res.statusCode = <span class="hljs-number">200</span>;
   res.setHeader(<span class="hljs-string">'Content-Type'</span>, <span class="hljs-string">'text/plain'</span>);

   <span class="hljs-comment">// Send the response body "Hello World"</span>
   res.end(<span class="hljs-string">'Hello World\n'</span>);
 });

 server.listen(port, hostname, <span class="hljs-function">() =&gt;</span> {
   <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Server running at http://<span class="hljs-subst">${hostname}</span>:<span class="hljs-subst">${port}</span>/`</span>);
 });
</code></pre>
</li>
</ol>
<h3 id="heading-step-3-run-your-server">Step 3: Run Your Server</h3>
<p>It's time to bring your server to life!</p>
<ol>
<li><p>Open your terminal or command prompt.</p>
</li>
<li><p>Navigate to the folder where you saved <code>app.js</code> (e.g., <code>cd my-node-app</code>).</p>
</li>
<li><p>Run the following command:</p>
</li>
</ol>
<p>Bash</p>
<pre><code class="lang-javascript">node app.js
</code></pre>
<p>You should see the message: <code>Server running at</code> <a target="_blank" href="http://127.0.0.1:3000/"><code>http://127.0.0.1:3000/</code></a>.</p>
<ol start="4">
<li>Now, open your web browser and go to that address. You'll see your "Hello World" message!</li>
</ol>
<p>Node.js breaks the traditional boundaries of web development, bringing the power and familiarity of JavaScript directly to the server. Its clever <strong>non-blocking architecture</strong> is the key to building fast, scalable, and efficient applications.</p>
<p>Your "Hello, World!" server is just the beginning. The true power of Node.js is unlocked when you explore its massive ecosystem through <strong>npm (Node Package Manager)</strong>.</p>
]]></content:encoded></item></channel></rss>