{"id":235,"date":"2026-10-23T14:03:23","date_gmt":"2026-10-23T14:03:23","guid":{"rendered":"https:\/\/devdojo.co.in\/?p=235"},"modified":"2026-10-23T14:03:24","modified_gmt":"2026-10-23T14:03:24","slug":"nodejs-series-part-1-what-is-nodejs","status":"publish","type":"post","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/","title":{"rendered":"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App"},"content":{"rendered":"\n<div class=\"dd-post\">\n<style>\n.single article:has(.dd-hero) .entry-media{display:none}\n.dd-post{--navy:#0b1020;--blue:#3178c6;--violet:#7c5cff;--ink:#1f2433;--muted:#5b6275;--line:#e3e6ef;font-size:17px;line-height:1.75;color:var(--ink)}\n.dd-post h2{margin:2.2em 0 .6em;font-size:1.6em;line-height:1.3;scroll-margin-top:90px}\n.dd-post h3{margin:1.6em 0 .5em;font-size:1.22em;scroll-margin-top:90px}\n.dd-post a{color:var(--blue);text-decoration:underline;text-underline-offset:3px}\n.dd-post pre{background:#0f1430;color:#e6e9f5;padding:18px 20px;border-radius:12px;overflow-x:auto;line-height:1.6;border:1px solid #232a52;margin:1.2em 0;font-size:14.5px !important}\n.dd-post pre code{font-size:1em !important;background:none;color:inherit;padding:0;font-family:\"JetBrains Mono\",\"Fira Code\",Consolas,Menlo,monospace;white-space:pre}\n.dd-post :not(pre)>code{background:#eef1fb;color:#2b3a8f;padding:2px 6px;border-radius:5px;font-size:.9em}\n.dd-post .dd-file{display:inline-block;background:#151b3b;color:#c9d1ff;font:600 13px\/1 \"JetBrains Mono\",Consolas,monospace;padding:7px 12px;border-radius:8px 8px 0 0;margin:1em 0 -1.2em;position:relative}\n.dd-post .dd-hero{margin:0 0 1.6em;border-radius:16px;overflow:hidden;box-shadow:0 10px 30px rgba(11,16,32,.25)}\n.dd-post .dd-hero svg{display:block;width:100%;height:auto}\n.dd-post .dd-hero .node{transition:transform .25s,filter .25s;transform-box:fill-box;transform-origin:center;cursor:pointer}\n.dd-post .dd-hero .node:hover{transform:scale(1.08);filter:drop-shadow(0 0 10px #7c5cff)}\n.dd-post .dd-series{display:inline-flex;align-items:center;gap:8px;background:#151b3b;color:#dfe3ff;border-radius:999px;padding:6px 14px;font-size:.88em;font-weight:600;margin:0 0 .8em}\n.dd-post .dd-series span{background:var(--violet);color:#fff;border-radius:999px;padding:2px 10px}\n.dd-post .dd-prereq{font-size:.96em;color:var(--muted);border-left:3px solid var(--line);padding-left:12px;margin:.6em 0 1.2em}\n.dd-post .dd-summary{background:linear-gradient(135deg,#eef3ff,#f4efff);border:1px solid #d6dcf5;border-left:5px solid var(--violet);border-radius:12px;padding:18px 22px;margin:1.4em 0}\n.dd-post .dd-summary strong.lbl{display:block;font-size:1.05em;margin-bottom:6px;color:#3a2fa0}\n.dd-post .dd-summary ul{margin:.3em 0 0 1.1em}\n.dd-post .dd-toc{background:#f8f9fc;border:1px solid var(--line);border-radius:12px;padding:16px 22px;margin:1.4em 0}\n.dd-post .dd-toc ol{margin:.4em 0 0 1.2em;columns:2;column-gap:28px}\n.dd-post .dd-toc li{break-inside:avoid;margin:.15em 0}\n@media(max-width:640px){.dd-post .dd-toc ol{columns:1}}\n.dd-post .dd-tip,.dd-post .dd-note,.dd-post .dd-warn{border-radius:10px;padding:14px 18px;margin:1.3em 0}\n.dd-post .dd-tip{background:#ecfbf3;border-left:4px solid #1f9d61}\n.dd-post .dd-note{background:#eef4ff;border-left:4px solid var(--blue)}\n.dd-post .dd-warn{background:#fff6e8;border-left:4px solid #e08a00}\n.dd-post .dd-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;margin:1.3em 0}\n.dd-post .dd-card{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fff;box-shadow:0 2px 8px rgba(20,30,70,.05)}\n.dd-post .dd-card b{display:block;color:#3a2fa0;margin-bottom:4px}\n.dd-post table{width:100%;border-collapse:collapse;margin:1.3em 0;font-size:.95em}\n.dd-post th,.dd-post td{border:1px solid var(--line);padding:10px 12px;text-align:left;vertical-align:top}\n.dd-post th{background:#151b3b;color:#fff}\n.dd-post tr:nth-child(even) td{background:#f8f9fc}\n.dd-post .dd-tablewrap{overflow-x:auto}\n.dd-post figure{margin:1.6em 0;text-align:center}\n.dd-post figure svg{width:100%;height:auto;border-radius:12px}\n.dd-post figcaption{font-size:.9em;color:var(--muted);margin-top:8px}\n.dd-post details{border:1px solid var(--line);border-radius:10px;padding:12px 16px;margin:.7em 0;background:#fff}\n.dd-post details summary{cursor:pointer;font-weight:600}\n.dd-post details[open] summary{margin-bottom:8px;color:#3a2fa0}\n.dd-post .dd-roadmap{border:2px solid #d6dcf5;background:#fbfbff}\n.dd-post .dd-roadmap h4{margin:1em 0 .3em;color:#151b3b;font-size:1em;text-transform:uppercase;letter-spacing:.04em}\n.dd-post .dd-roadmap ol{margin:.2em 0 .6em 1.4em;padding:0}\n.dd-post .dd-roadmap li{margin:.2em 0}\n.dd-post .dd-roadmap .here{background:var(--violet);color:#fff;border-radius:999px;padding:1px 9px;font-size:.8em;font-weight:700;margin-left:6px}\n.dd-post .dd-roadmap .soon{color:#8a90a6;font-size:.82em;margin-left:6px}\n.dd-post .dd-tabs{border:1px solid var(--line);border-radius:12px;padding:6px 16px 16px;margin:1.4em 0;background:#fbfbfe}\n.dd-post .dd-tabs>input{position:absolute;opacity:0;pointer-events:none}\n.dd-post .dd-tabs .labels label{display:inline-block;padding:8px 16px;margin:10px 6px 0 0;border-radius:999px;border:1px solid #cfd5ea;cursor:pointer;font-weight:600;font-size:.95em;background:#fff;transition:background .2s}\n.dd-post .dd-tabs .labels label:hover{border-color:var(--violet)}\n.dd-post .dd-tabs .panel{display:none;margin-top:12px}\n.dd-post .dd-tabs #ti1:checked~.labels label[for=ti1],.dd-post .dd-tabs #ti2:checked~.labels label[for=ti2],.dd-post .dd-tabs #ti3:checked~.labels label[for=ti3],.dd-post .dd-tabs #ti4:checked~.labels label[for=ti4]{background:var(--violet);color:#fff;border-color:var(--violet)}\n.dd-post .dd-tabs #ti1:checked~.p1,.dd-post .dd-tabs #ti2:checked~.p2,.dd-post .dd-tabs #ti3:checked~.p3,.dd-post .dd-tabs #ti4:checked~.p4{display:block}\n.dd-post .dd-tabs #ti1:focus-visible~.labels label[for=ti1],.dd-post .dd-tabs #ti2:focus-visible~.labels label[for=ti2],.dd-post .dd-tabs #ti3:focus-visible~.labels label[for=ti3],.dd-post .dd-tabs #ti4:focus-visible~.labels label[for=ti4]{outline:2px solid var(--blue);outline-offset:2px}\n.dd-post .dd-cta{background:linear-gradient(135deg,#0b1020,#151b3b);color:#e8ebff;border-radius:16px;padding:24px 26px;margin:2em 0;text-align:center}\n.dd-post .dd-cta h3{color:#fff;margin-top:0}\n.dd-post .dd-cta a{color:#a99bff}\n.dd-post .dd-vsc{position:relative;margin:1.5em 0;border-radius:12px;overflow:hidden;background:#1e1e1e;border:1px solid #2b2b2b;box-shadow:0 14px 34px rgba(0,0,0,.28);font-family:\"Segoe UI\",system-ui,sans-serif}\n.dd-post .dd-vsc>input{position:absolute;opacity:0;pointer-events:none}\n.dd-post .dd-vsc-bar{display:flex;align-items:center;gap:12px;background:#323233;color:#cccccc;font-size:12.5px;padding:8px 12px}\n.dd-post .dd-dots{display:inline-flex;gap:7px}.dd-post .dd-dots i{width:12px;height:12px;border-radius:50%;background:#ff5f57;display:block}.dd-post .dd-dots i:nth-child(2){background:#febc2e}.dd-post .dd-dots i:nth-child(3){background:#28c840}\n.dd-post .dd-vsc-title{flex:1;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:50px;opacity:.85}\n.dd-post .dd-vsc-tabs{display:flex;align-items:stretch;background:#252526;border-bottom:1px solid #1e1e1e;overflow-x:auto}\n.dd-post .dd-vsc-tabs label{display:flex;align-items:center;gap:7px;padding:9px 16px;color:#969696;font-size:13px;cursor:pointer;background:#2d2d2d;border-right:1px solid #252526;border-top:1px solid transparent;white-space:nowrap;margin:0;transition:color .15s}\n.dd-post .dd-vsc-tabs label:hover{color:#e0e0e0}\n.dd-post .dd-vsc-tabs .ic{font:700 9.5px\/1 Consolas,monospace;padding:3px 4px;border-radius:3px;color:#1e1e1e}\n.dd-post .ic.py{background:#ffd43b}.dd-post .ic.js{background:#f1e05a}.dd-post .ic.sh{background:#89e051}\n.dd-post .dd-vsc-tabs label.run{margin-left:auto;background:transparent;border:0;color:#89d185;font-weight:600;display:none}\n.dd-post .dd-vsc-tabs label.run:hover{color:#b5f0b0;background:#2a2d2e}\n.dd-post .dd-vsc-pane{display:none}\n.dd-post .dd-vsc>.f1:checked~.dd-vsc-tabs .t1,.dd-post .dd-vsc>.f2:checked~.dd-vsc-tabs .t2,.dd-post .dd-vsc>.f3:checked~.dd-vsc-tabs .t3{background:#1e1e1e;color:#ffffff;border-top-color:#3178c6}\n.dd-post .dd-vsc>.f1:checked~.p1,.dd-post .dd-vsc>.f2:checked~.p2,.dd-post .dd-vsc>.f3:checked~.p3{display:block}\n.dd-post .dd-vsc>.f1:checked~.dd-vsc-tabs .run1,.dd-post .dd-vsc>.f2:checked~.dd-vsc-tabs .run2,.dd-post .dd-vsc>.f3:checked~.dd-vsc-tabs .run3{display:flex}\n.dd-post .dd-vsc>.f1:focus-visible~.dd-vsc-tabs .t1,.dd-post .dd-vsc>.f2:focus-visible~.dd-vsc-tabs .t2,.dd-post .dd-vsc>.f3:focus-visible~.dd-vsc-tabs .t3,.dd-post .dd-vsc>input[type=checkbox]:focus-visible~.dd-vsc-tabs .run{outline:2px solid #3178c6;outline-offset:-2px}\n.dd-post .dd-vsc-crumbs{background:#1e1e1e;color:#a9a9a9;font-size:12px;padding:5px 16px 2px}\n.dd-post .dd-vsc pre.dd-vsc-code{background:#1e1e1e;color:#d4d4d4;border:0;border-radius:0;margin:0;padding:8px 0 14px;counter-reset:ln;line-height:1.62;overflow-x:auto}\n.dd-post .dd-vsc pre code{font-family:Consolas,\"JetBrains Mono\",\"Fira Code\",Menlo,monospace;color:inherit;background:none;white-space:pre}\n.dd-post .dd-vsc .l{display:inline-block;min-width:100%;padding-right:18px;box-sizing:border-box}\n.dd-post .dd-vsc .l::before{counter-increment:ln;content:counter(ln);display:inline-block;width:3.2em;padding-right:1.4em;text-align:right;color:#6e7681;user-select:none;-webkit-user-select:none}\n.dd-post .dd-vsc .l:hover{background:#2a2d2e}.dd-post .dd-vsc .l:hover::before{color:#c6c6c6}\n.dd-post .dd-vsc .k,.dd-post .dd-vsc .kn{color:#c586c0}.dd-post .dd-vsc .kc{color:#569cd6}.dd-post .dd-vsc .s{color:#ce9178}.dd-post .dd-vsc .c{color:#6a9955}.dd-post .dd-vsc .m{color:#b5cea8}.dd-post .dd-vsc .nf{color:#dcdcaa}.dd-post .dd-vsc .nc{color:#4ec9b0}.dd-post .dd-vsc .nb{color:#4ec9b0}.dd-post .dd-vsc .nd{color:#dcdcaa}.dd-post .dd-vsc .n{color:#9cdcfe}.dd-post .dd-vsc .o{color:#d4d4d4}.dd-post .dd-vsc .gp{color:#89d185;user-select:none;-webkit-user-select:none}\n.dd-post .dd-vsc-term{display:none;border-top:1px solid #3c3c3c;background:#181818}\n.dd-post .dd-vsc>.r1:checked~.p1 .dd-vsc-term,.dd-post .dd-vsc>.r2:checked~.p2 .dd-vsc-term,.dd-post .dd-vsc>.r3:checked~.p3 .dd-vsc-term{display:block;animation:ddterm .35s ease-out}\n@keyframes ddterm{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}\n.dd-post .dd-term-head{display:flex;gap:18px;align-items:center;font-size:11px;letter-spacing:.06em;color:#8b8b8b;padding:7px 16px 0}\n.dd-post .dd-term-head span:first-child{color:#e7e7e7;border-bottom:1px solid #e7e7e7;padding-bottom:4px}\n.dd-post .dd-term-head .dd-term-note{margin-left:auto;letter-spacing:0;text-transform:none;color:#d7ba7d;border:0;font-size:11.5px}\n.dd-post .dd-vsc-term pre{background:#181818;color:#cccccc;border:0;margin:0;padding:10px 16px 14px;border-radius:0}\n.dd-post .dd-vsc-status{display:flex;flex-wrap:wrap;gap:4px 14px;background:#007acc;color:#fff;font-size:11.5px;padding:4px 12px}\n.dd-post .dd-vsc-status .sp{flex:1}\n.dd-post .dd-vsc-termonly pre.dd-vsc-code{background:#181818;padding:12px 16px}\n@media(max-width:640px){.dd-post .dd-vsc-title{padding-right:0;text-align:left}.dd-post .dd-vsc-status span:nth-child(n+4){display:none}.dd-post .dd-vsc .l::before{width:2.2em;padding-right:1em}}\n.dd-post .dd-vsc-hint{font-size:.93em;color:var(--muted);margin-top:-.6em}\n.dd-post .dd-next{border:1px dashed var(--violet);border-radius:12px;padding:16px 20px;margin:1.6em 0;background:#f7f4ff}\n.dd-post .ic.yml{background:#cb3837;color:#fff}\n.dd-post .ic.jsx{background:#61dafb}.dd-post .ic.html{background:#e44d26;color:#fff}.dd-post .ic.css{background:#563d7c;color:#fff}\n.dd-post .dd-steps{counter-reset:st;list-style:none;margin:1.2em 0;padding:0}\n.dd-post .dd-steps>li{position:relative;padding:0 0 0 46px;margin:0 0 14px}\n.dd-post .dd-steps>li::before{counter-increment:st;content:counter(st);position:absolute;left:0;top:2px;width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,#3178c6,#7c5cff);color:#fff;font-weight:700;text-align:center;line-height:32px}\n<\/style>\n\n<div class=\"dd-hero\">\n<svg viewBox=\"0 0 1200 520\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"Node.js series Part 1 banner: a hexagon Node.js badge with orbiting dots, and requests flowing through the event loop to the file system, network and database\">\n<defs>\n<linearGradient id=\"ddbg\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#0b1020\"\/><stop offset=\"1\" stop-color=\"#151b3b\"\/><\/linearGradient>\n<linearGradient id=\"ddac\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stop-color=\"#3178c6\"\/><stop offset=\"1\" stop-color=\"#7c5cff\"\/><\/linearGradient>\n<linearGradient id=\"ddgr\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#5fa04e\"\/><stop offset=\"1\" stop-color=\"#3c873a\"\/><\/linearGradient>\n<radialGradient id=\"ddglow\" cx=\".5\" cy=\".5\" r=\".5\"><stop offset=\"0\" stop-color=\"#7c5cff\" stop-opacity=\".45\"\/><stop offset=\"1\" stop-color=\"#7c5cff\" stop-opacity=\"0\"\/><\/radialGradient>\n<\/defs>\n<rect x=\"0\" y=\"-60\" width=\"1200\" height=\"640\" fill=\"url(#ddbg)\"\/>\n<circle cx=\"930\" cy=\"230\" r=\"270\" fill=\"url(#ddglow)\"\/>\n<g opacity=\".12\" stroke=\"#9fb2ff\"><path d=\"M0 100H1200M0 200H1200M0 300H1200M0 400H1200M200 0V520M400 0V520M600 0V520M800 0V520M1000 0V520\"\/><\/g>\n<rect x=\"60\" y=\"46\" width=\"128\" height=\"38\" rx=\"19\" fill=\"url(#ddac)\"\/>\n<text x=\"124\" y=\"71\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"700\" fill=\"#fff\">PART 1<\/text>\n<text x=\"204\" y=\"71\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" fill=\"#aab4e8\">Node.js Series \u00b7 DevDojo<\/text>\n<text x=\"60\" y=\"148\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"52\" font-weight=\"800\" fill=\"#ffffff\">What Is Node.js?<\/text>\n<text x=\"60\" y=\"206\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"52\" font-weight=\"800\" fill=\"#ffffff\">Your First Node.js App<\/text>\n<text x=\"60\" y=\"250\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"24\" fill=\"#c9d1ff\">Runtime, event loop and your first web server<\/text>\n<g transform=\"translate(930 220)\">\n<ellipse id=\"ddor\" cx=\"0\" cy=\"0\" rx=\"200\" ry=\"78\" fill=\"none\" stroke=\"url(#ddac)\" stroke-width=\"4\" opacity=\".85\"\/>\n<path id=\"ddo1\" d=\"M-200 0 A200 78 0 1 1 200 0 A200 78 0 1 1 -200 0 Z\" fill=\"none\" stroke=\"none\"\/>\n<g class=\"node\"><polygon points=\"0,-80 69,-40 69,40 0,80 -69,40 -69,-40\" fill=\"url(#ddgr)\" stroke=\"#8fd16a\" stroke-width=\"3\"\/><text y=\"12\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"34\" font-weight=\"800\" fill=\"#fff\">JS<\/text><\/g>\n<circle r=\"9\" fill=\"#ffffff\"><animateMotion dur=\"5s\" repeatCount=\"indefinite\"><mpath href=\"#ddo1\"\/><\/animateMotion><\/circle>\n<circle r=\"8\" fill=\"#7c5cff\"><animateMotion dur=\"5s\" begin=\"-2.5s\" repeatCount=\"indefinite\"><mpath href=\"#ddo1\"\/><\/animateMotion><\/circle>\n<\/g>\n<g class=\"node\"><rect x=\"60\" y=\"330\" width=\"150\" height=\"48\" rx=\"12\" fill=\"#0b1020\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"135\" y=\"360\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"17\" font-weight=\"700\" fill=\"#c9d1ff\">Requests<\/text><\/g>\n<g class=\"node\"><rect x=\"290\" y=\"322\" width=\"190\" height=\"64\" rx=\"32\" fill=\"url(#ddac)\"\/><text x=\"385\" y=\"361\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"800\" fill=\"#fff\">Event loop<\/text><\/g>\n<g class=\"node\"><rect x=\"560\" y=\"300\" width=\"160\" height=\"40\" rx=\"10\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"640\" y=\"326\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" font-weight=\"700\" fill=\"#c9d1ff\">File system<\/text><\/g>\n<g class=\"node\"><rect x=\"560\" y=\"350\" width=\"160\" height=\"40\" rx=\"10\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"640\" y=\"376\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" font-weight=\"700\" fill=\"#c9d1ff\">Network<\/text><\/g>\n<g class=\"node\"><rect x=\"560\" y=\"400\" width=\"160\" height=\"40\" rx=\"10\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"640\" y=\"426\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" font-weight=\"700\" fill=\"#c9d1ff\">Database<\/text><\/g>\n<path d=\"M210 354H290M480 354H520V320H560M520 354V370H560M520 370V420H560\" stroke=\"#7c5cff\" stroke-width=\"2.5\" fill=\"none\" opacity=\".8\"\/>\n<path id=\"ddflow\" d=\"M210 354H290M480 354H520V420H560\" fill=\"none\" stroke=\"none\"\/>\n<circle r=\"6\" fill=\"#61dafb\"><animateMotion dur=\"3s\" repeatCount=\"indefinite\"><mpath href=\"#ddflow\"\/><\/animateMotion><\/circle>\n<path id=\"ddflow2\" d=\"M210 354H520V320H560\" fill=\"none\" stroke=\"none\"\/>\n<circle r=\"6\" fill=\"#8fd16a\"><animateMotion dur=\"3.6s\" begin=\"1s\" repeatCount=\"indefinite\"><mpath href=\"#ddflow2\"\/><\/animateMotion><\/circle>\n<text x=\"760\" y=\"376\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"17\" fill=\"#aab4e8\">Never waits, always busy<\/text>\n<text x=\"60\" y=\"505\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"16\" fill=\"#7f89b5\">devdojo.co.in \u00b7 Beginner friendly \u00b7 Works on Node.js 22, 24 and 26<\/text>\n<\/svg>\n<\/div>\n\n<div class=\"dd-series\">Series: Node.js <span>Part 1 of 30<\/span><\/div>\n<p class=\"dd-prereq\"><strong>What you should know first:<\/strong> this is the first part, so no earlier part is needed. You should know basic JavaScript (variables, functions, arrays, objects and arrow functions). If promises still feel new, keep our <a href=\"https:\/\/devdojo.co.in\/index.php\/2024\/08\/12\/mastering-javascript-promises-a-guide-to-asynchronous-programming\/\">JavaScript Promises guide<\/a> open for later parts.<\/p>\n\n<p>If you have written JavaScript for the browser, you already know half of backend development. <strong>Node.js<\/strong> lets the same language run outside the browser: on your laptop, on a server, inside build tools and in the cloud. In this first part of the Node.js series you will learn, in simple words, <strong>what is Node.js<\/strong>, how it is different from browser JavaScript, and why its \u201cnever wait\u201d design makes it so good for web servers and APIs. Then you will install it, write your first scripts, and build a small web server with zero packages.<\/p>\n\n<div class=\"dd-summary\">\n<strong class=\"lbl\">Quick Summary<\/strong>\n<ul>\n<li><strong>Node.js<\/strong> is a free, open-source <strong>JavaScript runtime<\/strong>: a program that runs JavaScript outside the browser, built on Google&#8217;s <strong>V8 engine<\/strong>.<\/li>\n<li>It adds what servers need and browsers do not have: <strong>files<\/strong> (<code>fs<\/code>), <strong>network servers<\/strong> (<code>http<\/code>), the <strong>operating system<\/strong> (<code>os<\/code>, <code>process<\/code>) and the huge <strong>npm<\/strong> package library.<\/li>\n<li>Node.js is <strong>non-blocking<\/strong>: slow work (files, network, databases) runs in the background, and the <strong>event loop<\/strong> runs your callback when the result is ready. One process can serve thousands of users.<\/li>\n<li>Install the <strong>LTS<\/strong> (long-term support) version, then run a file with <code>node hello.js<\/code>.<\/li>\n<li>A web server needs only the built-in <code>node:http<\/code> module; <code>node --watch<\/code> restarts it whenever you save.<\/li>\n<\/ul>\n<\/div>\n\n<details class=\"dd-roadmap\">\n<summary>Full Node.js roadmap (30 parts)<\/summary>\n<h4>Beginner<\/h4>\n<ol start=\"1\">\n<li>What Is Node.js and How to Build Your First Node.js App <span class=\"here\">You are here<\/span><\/li>\n<li>Modules in Node.js: ES Modules, CommonJS and import\/export <span class=\"soon\">Coming soon<\/span><\/li>\n<li>npm and package.json: Installing and Managing Packages <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Working with Files and Folders: the fs and path Modules <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Asynchronous Node.js: Callbacks, Promises and async\/await <span class=\"soon\">Coming soon<\/span><\/li>\n<li>The Event Loop Explained Simply <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Events and EventEmitter: Building Event-Driven Code <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Streams and Buffers: Handling Large Data Efficiently <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Building a Web Server with the http Module <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Mini Project: Build a Command-Line Tool with Node.js <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<h4>Intermediate<\/h4>\n<ol start=\"11\">\n<li>Express.js Basics: Routes, Requests and Responses <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Middleware in Express: How Requests Flow <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Build a REST API with Express: Full CRUD <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Validating Request Data with Zod <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Environment Variables and Configuration (&#8211;env-file and .env) <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Connecting Node.js to PostgreSQL <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Using an ORM: Prisma vs Drizzle <span class=\"soon\">Coming soon<\/span><\/li>\n<li>MongoDB with Mongoose <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Authentication: Password Hashing, Sessions and JWT <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Error Handling and Logging with Pino <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<h4>Advanced<\/h4>\n<ol start=\"21\">\n<li>Testing Node.js Apps with node:test and Supertest <span class=\"soon\">Coming soon<\/span><\/li>\n<li>TypeScript with Node.js: Running .ts Files Directly <span class=\"soon\">Coming soon<\/span><\/li>\n<li>File Uploads and Image Processing <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Real-Time Apps with WebSockets and Socket.IO <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Caching with Redis <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Background Jobs and Queues with BullMQ <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Worker Threads and Clustering for Performance <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Security Best Practices for Node.js APIs <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Debugging, Profiling and Performance Tuning <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Final Project: Build and Deploy a Production-Ready Node.js API <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<\/details>\n\n<nav class=\"dd-toc\" aria-label=\"Table of contents\">\n<strong>In this part<\/strong>\n<ol>\n<li><a href=\"#what-is-nodejs\">What is Node.js?<\/a><\/li>\n<li><a href=\"#browser-vs-node\">Browser JavaScript vs Node.js<\/a><\/li>\n<li><a href=\"#how-node-works\">How Node.js works: the event loop<\/a><\/li>\n<li><a href=\"#what-can-you-build\">What can you build with Node.js?<\/a><\/li>\n<li><a href=\"#install\">Install Node.js<\/a><\/li>\n<li><a href=\"#repl\">Try the Node.js REPL<\/a><\/li>\n<li><a href=\"#first-script\">Your first Node.js script<\/a><\/li>\n<li><a href=\"#non-blocking\">See non-blocking code in action<\/a><\/li>\n<li><a href=\"#first-server\">Build your first web server<\/a><\/li>\n<li><a href=\"#package-json\">package.json, scripts and &#8211;watch<\/a><\/li>\n<li><a href=\"#common-errors\">Common errors and fixes<\/a><\/li>\n<li><a href=\"#best-practices\">Best practices<\/a><\/li>\n<li><a href=\"#practice\">Practice task<\/a><\/li>\n<li><a href=\"#faq\">FAQ<\/a><\/li>\n<\/ol>\n<\/nav>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"what-is-nodejs\">What is Node.js? (simple definition)<\/h2>\n<p><strong>Node.js<\/strong> is a <strong>JavaScript runtime<\/strong>. A runtime is the environment that actually runs your code. Before Node.js, the only place JavaScript could run was inside a web browser. In 2009 Ryan Dahl took <strong>V8<\/strong>, the very fast JavaScript engine from Google Chrome, and wrapped it in a program that can run on any computer and talk to the file system and the network. That program is Node.js.<\/p>\n<div class=\"dd-note\"><strong>In one line:<\/strong> Node.js lets you run JavaScript on a computer or server (not just in a browser), so you can build backends, APIs, command-line tools and much more with one language.<\/div>\n<p>Three words help you understand it:<\/p>\n<div class=\"dd-cards\">\n<div class=\"dd-card\"><b>Runtime, not a language<\/b>The language is still JavaScript. Node.js is the place where it runs, like the browser is for frontend code.<\/div>\n<div class=\"dd-card\"><b>Not a framework<\/b>Node.js gives you building blocks. Frameworks such as Express, Fastify and NestJS are built on top of it (we will learn them later in this series).<\/div>\n<div class=\"dd-card\"><b>Open source<\/b>Node.js is free and maintained by the OpenJS Foundation and a large community. New major versions arrive regularly; even-numbered ones become <strong>LTS<\/strong>.<\/div>\n<\/div>\n<p>Node.js is used by companies such as Netflix, PayPal, LinkedIn, Uber, Walmart and many Indian startups and product companies for APIs and web servers. It also powers almost every modern frontend tool: Vite, Next.js, ESLint and TypeScript all run on Node.js. So even frontend developers use it every day. The official site <a href=\"https:\/\/nodejs.org\/en\/learn\/getting-started\/introduction-to-nodejs\" target=\"_blank\" rel=\"noopener\">nodejs.org\/learn<\/a> has a good free introduction too.<\/p>\n\n<h2 id=\"browser-vs-node\">Browser JavaScript vs Node.js<\/h2>\n<p>The language is the same: <code>let<\/code>, <code>const<\/code>, functions, arrays, objects, promises and <code>async\/await<\/code> all work exactly as you know them. What changes is the <strong>toolbox<\/strong> around the language.<\/p>\n<figure>\n<svg viewBox=\"0 0 1000 400\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"JavaScript in the browser versus JavaScript in Node.js. Both use a JavaScript engine. The browser adds the DOM, window and fetch. Node.js adds files, network servers, operating system access and npm packages.\">\n<rect width=\"1000\" height=\"400\" rx=\"14\" fill=\"#0b1020\"\/>\n<g font-family=\"Segoe UI,Arial,sans-serif\">\n<rect x=\"40\" y=\"40\" width=\"430\" height=\"320\" rx=\"16\" fill=\"#131a3d\" stroke=\"#3178c6\" stroke-width=\"2\"\/>\n<rect x=\"530\" y=\"40\" width=\"430\" height=\"320\" rx=\"16\" fill=\"#131a3d\" stroke=\"#5fa04e\" stroke-width=\"2\"\/>\n<text x=\"255\" y=\"82\" text-anchor=\"middle\" font-size=\"24\" font-weight=\"800\" fill=\"#8ab8ff\">Browser<\/text>\n<text x=\"745\" y=\"82\" text-anchor=\"middle\" font-size=\"24\" font-weight=\"800\" fill=\"#8fd16a\">Node.js<\/text>\n<rect x=\"80\" y=\"104\" width=\"350\" height=\"50\" rx=\"10\" fill=\"url(#ddac2)\"\/><text x=\"255\" y=\"136\" text-anchor=\"middle\" font-size=\"18\" font-weight=\"700\" fill=\"#fff\">JavaScript engine (V8, etc.)<\/text>\n<rect x=\"570\" y=\"104\" width=\"350\" height=\"50\" rx=\"10\" fill=\"url(#ddac2)\"\/><text x=\"745\" y=\"136\" text-anchor=\"middle\" font-size=\"18\" font-weight=\"700\" fill=\"#fff\">V8 engine + libuv<\/text>\n<g font-size=\"17\" fill=\"#e6e9f5\">\n<rect x=\"80\" y=\"172\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2250\"\/><text x=\"164\" y=\"200\" text-anchor=\"middle\">DOM, document<\/text>\n<rect x=\"262\" y=\"172\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2250\"\/><text x=\"346\" y=\"200\" text-anchor=\"middle\">window, alert()<\/text>\n<rect x=\"80\" y=\"228\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2250\"\/><text x=\"164\" y=\"256\" text-anchor=\"middle\">localStorage<\/text>\n<rect x=\"262\" y=\"228\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2250\"\/><text x=\"346\" y=\"256\" text-anchor=\"middle\">fetch(), timers<\/text>\n<rect x=\"570\" y=\"172\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2a2a\"\/><text x=\"654\" y=\"200\" text-anchor=\"middle\">Files (fs)<\/text>\n<rect x=\"752\" y=\"172\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2a2a\"\/><text x=\"836\" y=\"200\" text-anchor=\"middle\">Web servers (http)<\/text>\n<rect x=\"570\" y=\"228\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2a2a\"\/><text x=\"654\" y=\"256\" text-anchor=\"middle\">OS, process<\/text>\n<rect x=\"752\" y=\"228\" width=\"168\" height=\"44\" rx=\"10\" fill=\"#1b2a2a\"\/><text x=\"836\" y=\"256\" text-anchor=\"middle\">fetch(), timers<\/text>\n<\/g>\n<text x=\"255\" y=\"318\" text-anchor=\"middle\" font-size=\"17\" fill=\"#aab4e8\">Runs on the user&#8217;s device, sandboxed<\/text>\n<text x=\"745\" y=\"318\" text-anchor=\"middle\" font-size=\"17\" fill=\"#aab4e8\">Runs on your computer or server<\/text>\n<\/g>\n<defs><linearGradient id=\"ddac2\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stop-color=\"#3178c6\"\/><stop offset=\"1\" stop-color=\"#7c5cff\"\/><\/linearGradient><\/defs>\n<\/svg>\n<figcaption>Same language, different toolbox: the browser gives JavaScript the page, Node.js gives it files, servers and the operating system.<\/figcaption>\n<\/figure>\n<div class=\"dd-tablewrap\"><table>\n<thead><tr><th>Topic<\/th><th>Browser<\/th><th>Node.js<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>Where it runs<\/td><td>On the visitor&#8217;s device, inside a tab<\/td><td>On your computer or a server<\/td><\/tr>\n<tr><td>Main job<\/td><td>Show pages and react to clicks<\/td><td>Serve APIs, read files, talk to databases, run tools<\/td><\/tr>\n<tr><td>Special objects<\/td><td><code>document<\/code>, <code>window<\/code>, <code>localStorage<\/code><\/td><td><code>process<\/code>, <code>fs<\/code>, <code>http<\/code>, <code>os<\/code>, <code>path<\/code><\/td><\/tr>\n<tr><td>Access to files<\/td><td>No (only files the user picks)<\/td><td>Yes, full access to the file system<\/td><\/tr>\n<tr><td>Who controls the version<\/td><td>The user&#8217;s browser<\/td><td>You do, so you can use the newest features<\/td><\/tr>\n<tr><td>Packages<\/td><td>Bundled by tools like Vite<\/td><td>Installed with <strong>npm<\/strong> and imported directly<\/td><\/tr>\n<\/tbody><\/table><\/div>\n<div class=\"dd-tip\"><strong>Good news:<\/strong> modern Node.js also has many browser APIs built in, like <code>fetch()<\/code>, <code>URL<\/code>, <code>setTimeout<\/code>, <code>structuredClone<\/code> and Web Streams. Code you learned for the browser often works in Node.js without changes.<\/div>\n\n<h2 id=\"how-node-works\">How Node.js works: the event loop in simple words<\/h2>\n<p>Think of a busy restaurant with <strong>one very fast waiter<\/strong>. The waiter takes your order, gives it to the kitchen, and immediately goes to the next table. They do not stand in the kitchen waiting for your food. When a dish is ready, the kitchen rings a bell and the waiter delivers it.<\/p>\n<p>Node.js works the same way:<\/p>\n<ul class=\"dd-steps\">\n<li><strong>Your JavaScript runs on one main thread<\/strong> (the waiter). It runs one piece of code at a time.<\/li>\n<li><strong>Slow work is handed off<\/strong> (to the kitchen). Reading a file, calling another API or querying a database is done by the operating system and a C library called <strong>libuv<\/strong>, in the background.<\/li>\n<li><strong>Finished work waits in a queue<\/strong> (the bell). Each finished job has a callback, a function you gave Node.js to run \u201cwhen it is done\u201d.<\/li>\n<li><strong>The event loop delivers results<\/strong>. Whenever the main thread is free, the event loop takes the next callback from the queue and runs it.<\/li>\n<\/ul>\n<figure>\n<svg viewBox=\"0 0 1000 430\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"How Node.js handles slow work. Your JavaScript runs on one main thread. Slow tasks such as reading a file or a database query are handed to the system and libuv. When they finish, their callbacks wait in a queue, and the event loop runs them one by one.\">\n<rect width=\"1000\" height=\"430\" rx=\"14\" fill=\"#0b1020\"\/>\n<g font-family=\"Segoe UI,Arial,sans-serif\">\n<rect x=\"40\" y=\"60\" width=\"250\" height=\"300\" rx=\"16\" fill=\"#131a3d\" stroke=\"#3178c6\" stroke-width=\"2\"\/>\n<text x=\"165\" y=\"96\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#8ab8ff\">1. Your code<\/text>\n<text x=\"165\" y=\"122\" text-anchor=\"middle\" font-size=\"15\" fill=\"#aab4e8\">one main thread<\/text>\n<g font-size=\"15\" fill=\"#e6e9f5\"><rect x=\"70\" y=\"140\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2250\"\/><text x=\"165\" y=\"166\" text-anchor=\"middle\">console.log(&#8220;1&#8221;)<\/text>\n<rect x=\"70\" y=\"192\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2250\"\/><text x=\"165\" y=\"218\" text-anchor=\"middle\">readFile(&#8230;)<\/text>\n<rect x=\"70\" y=\"244\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2250\"\/><text x=\"165\" y=\"270\" text-anchor=\"middle\">setTimeout(&#8230;)<\/text>\n<rect x=\"70\" y=\"296\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2250\"\/><text x=\"165\" y=\"322\" text-anchor=\"middle\">console.log(&#8220;2&#8221;)<\/text><\/g>\n<rect x=\"375\" y=\"60\" width=\"250\" height=\"300\" rx=\"16\" fill=\"#131a3d\" stroke=\"#7c5cff\" stroke-width=\"2\"\/>\n<text x=\"500\" y=\"96\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#b9a8ff\">2. Slow work<\/text>\n<text x=\"500\" y=\"122\" text-anchor=\"middle\" font-size=\"15\" fill=\"#aab4e8\">done by the OS and libuv<\/text>\n<g font-size=\"15\" fill=\"#e6e9f5\"><rect x=\"405\" y=\"150\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#24204f\"\/><text x=\"500\" y=\"176\" text-anchor=\"middle\">reading a file\u2026<\/text>\n<rect x=\"405\" y=\"204\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#24204f\"\/><text x=\"500\" y=\"230\" text-anchor=\"middle\">waiting for a timer\u2026<\/text>\n<rect x=\"405\" y=\"258\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#24204f\"\/><text x=\"500\" y=\"284\" text-anchor=\"middle\">database query\u2026<\/text><\/g>\n<rect x=\"710\" y=\"60\" width=\"250\" height=\"300\" rx=\"16\" fill=\"#131a3d\" stroke=\"#5fa04e\" stroke-width=\"2\"\/>\n<text x=\"835\" y=\"96\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#8fd16a\">3. Callback queue<\/text>\n<text x=\"835\" y=\"122\" text-anchor=\"middle\" font-size=\"15\" fill=\"#aab4e8\">finished jobs wait here<\/text>\n<g font-size=\"15\" fill=\"#e6e9f5\"><rect x=\"740\" y=\"150\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2a2a\"\/><text x=\"835\" y=\"176\" text-anchor=\"middle\">timer done \u2192 run<\/text>\n<rect x=\"740\" y=\"204\" width=\"190\" height=\"40\" rx=\"9\" fill=\"#1b2a2a\"\/><text x=\"835\" y=\"230\" text-anchor=\"middle\">file ready \u2192 run<\/text><\/g>\n<path d=\"M290 212H375\" stroke=\"#7c5cff\" stroke-width=\"3\" marker-end=\"url(#ddar)\"\/>\n<path d=\"M625 212H710\" stroke=\"#5fa04e\" stroke-width=\"3\" marker-end=\"url(#ddar)\"\/>\n<path id=\"ddback\" d=\"M835 360 V395 H165 V360\" fill=\"none\" stroke=\"#3178c6\" stroke-width=\"3\" stroke-dasharray=\"8 6\" marker-end=\"url(#ddar)\"\/>\n<circle r=\"7\" fill=\"#61dafb\"><animateMotion dur=\"4s\" repeatCount=\"indefinite\"><mpath href=\"#ddback\"\/><\/animateMotion><\/circle>\n<text x=\"500\" y=\"420\" text-anchor=\"middle\" font-size=\"16\" font-weight=\"700\" fill=\"#c9d1ff\">The event loop: when the main thread is free, run the next waiting callback<\/text>\n<defs><marker id=\"ddar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#c9d1ff\"\/><\/marker><\/defs>\n<\/g>\n<\/svg>\n<figcaption>Node.js never sits idle waiting for a file or the network. It hands slow work to the system and keeps running your code; the event loop runs each callback when its result is ready.<\/figcaption>\n<\/figure>\n<p>This style is called <strong>non-blocking I\/O<\/strong> (I\/O means input\/output: files, network, databases). Because the main thread never waits, a single Node.js process can handle thousands of users at the same time, as long as each request does mostly I\/O and not heavy number crunching.<\/p>\n<div class=\"dd-warn\"><strong>The one rule to remember:<\/strong> never block the main thread. A long <code>for<\/code> loop that runs for 5 seconds freezes every user on your server for 5 seconds. Heavy CPU work belongs in worker threads or a separate service (we cover this in Part 27).<\/div>\n<p>We will study the event loop deeply in Part 6. For now, the restaurant picture is all you need.<\/p>\n\n<h2 id=\"what-can-you-build\">What can you build with Node.js?<\/h2>\n<div class=\"dd-cards\">\n<div class=\"dd-card\"><b>REST and GraphQL APIs<\/b>The backend for web and mobile apps: login, payments, orders, search.<\/div>\n<div class=\"dd-card\"><b>Real-time apps<\/b>Chat, live dashboards, multiplayer games and notifications with WebSockets.<\/div>\n<div class=\"dd-card\"><b>Full-stack web apps<\/b>Next.js, Nuxt and Remix run their server parts on Node.js.<\/div>\n<div class=\"dd-card\"><b>Command-line tools<\/b>Scripts and CLIs like <code>npm<\/code>, <code>vite<\/code> and <code>eslint<\/code>.<\/div>\n<div class=\"dd-card\"><b>Automation and AI agents<\/b>Bots, scrapers, cron jobs and LLM-powered tools that call APIs.<\/div>\n<div class=\"dd-card\"><b>Microservices<\/b>Small services in Docker containers, deployed with CI\/CD pipelines.<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"install\">Install Node.js (choose the LTS version)<\/h2>\n<p>On <a href=\"https:\/\/nodejs.org\/en\/download\" target=\"_blank\" rel=\"noopener\">nodejs.org\/download<\/a> you will see two kinds of versions. <strong>LTS<\/strong> (Long Term Support) gets bug and security fixes for about 30 months, which is why companies use it in production. <strong>Current<\/strong> has the newest features but changes faster. As a beginner, always pick <strong>LTS<\/strong>. Everything in this series works on Node.js 22, 24 and 26.<\/p>\n<div class=\"dd-tabs\" role=\"group\" aria-label=\"Install Node.js on your operating system\">\n<input type=\"radio\" name=\"ddos\" id=\"ti1\" checked>\n<input type=\"radio\" name=\"ddos\" id=\"ti2\">\n<input type=\"radio\" name=\"ddos\" id=\"ti3\">\n<div class=\"labels\"><label for=\"ti1\">Windows<\/label><label for=\"ti2\">macOS<\/label><label for=\"ti3\">Linux \/ WSL<\/label><\/div>\n<div class=\"panel p1\">\n<p>The easiest way on Windows is the official <strong>LTS installer<\/strong> from nodejs.org. It also installs npm and adds <code>node<\/code> to your PATH. If you like the terminal, <code>winget<\/code> does the same in one command.<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: Windows PowerShell\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">Windows PowerShell<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Option 1: download the LTS installer from nodejs.org and click Next<\/span><\/span>\n<span class=\"l\"><span class=\"c\"># Option 2: use winget (built into Windows 10 and 11)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> winget install OpenJS.NodeJS.LTS<\/span>\n<span class=\"l\"><span class=\"c\"># Close and reopen the terminal, then check:<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node -v<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> npm -v<\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"panel p2\">\n<p>On a Mac we recommend <strong>nvm<\/strong>. It lets you install many Node.js versions side by side and switch between them, which you will need when different projects use different versions.<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: macOS \u2014 zsh\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">macOS \u2014 zsh<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Install nvm (check github.com\/nvm-sh\/nvm for the newest version)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.40.3\/install.sh | bash<\/span>\n<span class=\"l\"><span class=\"c\"># Restart the terminal, then install the latest LTS version<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> nvm install --lts<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> nvm use --lts<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node -v<\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"panel p3\">\n<p>On Ubuntu, Debian or WSL, skip the old <code>apt install nodejs<\/code> package (it is often years behind). Use <strong>nvm<\/strong> instead:<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: Ubuntu \u2014 bash\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">Ubuntu \u2014 bash<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Same nvm steps work on Linux and WSL<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.40.3\/install.sh | bash<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> source ~\/.bashrc<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> nvm install --lts<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node -v<\/span>\n<span class=\"l\"><span class=\"c\"># Switch versions any time, per project<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> nvm install 24<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> nvm use 24<\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Pick your operating system above to see the right install steps.<\/p>\n<p>Now open a new terminal and check that both <code>node<\/code> and <code>npm<\/code> (the package manager that comes with Node.js) are ready. Your version numbers may be newer; that is fine.<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: node-part1 \u2014 bash\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">node-part1 \u2014 bash<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Check that Node.js and npm are installed<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node -v<\/span>\n<span class=\"l\">v22.22.0<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> npm -v<\/span>\n<span class=\"l\">10.9.4<\/span><\/code><\/pre>\n<\/div>\n\n<h2 id=\"repl\">Try the Node.js REPL (a JavaScript playground)<\/h2>\n<p>Type <code>node<\/code> with no file name and you enter the <strong>REPL<\/strong> (Read, Evaluate, Print, Loop). It reads a line of JavaScript, runs it, prints the result and waits for the next line. It is perfect for quick experiments.<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: node \u2014 REPL\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">node \u2014 REPL<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"gp\">$<\/span> node<\/span>\n<span class=\"l\">Welcome to Node.js v22.22.0.<\/span>\n<span class=\"l\">Type \".help\" for more information.<\/span>\n<span class=\"l\">&gt; 2 + 3<\/span>\n<span class=\"l\">5<\/span>\n<span class=\"l\">&gt; \"devdojo\".toUpperCase()<\/span>\n<span class=\"l\">'DEVDOJO'<\/span>\n<span class=\"l\">&gt; [1, 2, 3].map(n =&gt; n * 2)<\/span>\n<span class=\"l\">[ 2, 4, 6 ]<\/span>\n<span class=\"l\">&gt; .exit<\/span><\/code><\/pre>\n<\/div>\n<p>Press <code>Ctrl + C<\/code> twice or type <code>.exit<\/code> to leave. Use the REPL to test small ideas; use files for real programs.<\/p>\n\n<h2 id=\"first-script\">Your first Node.js script<\/h2>\n<p>Create a folder called <code>node-part1<\/code>, open it in VS Code, and create a file named <code>hello.js<\/code>. This script greets you and prints some facts about your machine, things a browser is <em>not allowed<\/em> to tell a web page.<\/p>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: hello.js\">\n<input type=\"radio\" name=\"v1\" id=\"v1f1\" class=\"f1\" checked>\n<input type=\"checkbox\" id=\"v1r1\" class=\"r1\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">hello.js \u2014 node-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v1f1\" class=\"t1\"><b class=\"ic js\">JS<\/b>hello.js<\/label>\n<label for=\"v1r1\" class=\"run run1\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">node-part1 \u203a hello.js<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ hello.js \u2013 your first Node.js program<\/span><\/span>\n<span class=\"l\"><span class=\"k\">import<\/span> <span class=\"n\">os<\/span> <span class=\"k\">from<\/span> <span class=\"s\">\"node:os\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">name<\/span> = <span class=\"nb\">process<\/span>.<span class=\"n\">argv<\/span>[<span class=\"m\">2<\/span>] ?? <span class=\"s\">\"DevDojo reader\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">`Hello, ${<\/span><span class=\"n\">name<\/span><span class=\"s\">}!`<\/span>);<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"Node.js version:\"<\/span>, <span class=\"nb\">process<\/span>.<span class=\"n\">version<\/span>);<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"Operating system:\"<\/span>, <span class=\"n\">os<\/span>.<span class=\"nf\">platform<\/span>());<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"CPU cores:\"<\/span>, <span class=\"n\">os<\/span>.<span class=\"nf\">cpus<\/span>().<span class=\"n\">length<\/span>);<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output (Node.js 22, Linux)<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node hello.js Lokendra\nHello, Lokendra!\nNode.js version: v22.22.0\nOperating system: linux\nCPU cores: 2<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 9, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Click <strong>\u25b6 Run<\/strong> to see the real output in the terminal panel.<\/p>\n<p>Let&#8217;s read it line by line:<\/p>\n<ul>\n<li><code>import os from \"node:os\"<\/code> loads a <strong>built-in module<\/strong>. The <code>node:<\/code> prefix makes it clear this is part of Node.js itself, not an npm package. (To use <code>import<\/code> in a <code>.js<\/code> file, add <code>\"type\": \"module\"<\/code> to <code>package.json<\/code>; we do that below. Recent Node.js versions also detect it automatically.)<\/li>\n<li><code>process<\/code> is a global object about the running program. <code>process.argv<\/code> is the list of words you typed in the terminal, so <code>process.argv[2]<\/code> is the first extra word (<code>Lokendra<\/code>).<\/li>\n<li><code>??<\/code> gives a default value when nothing was typed.<\/li>\n<li><code>process.version<\/code>, <code>os.platform()<\/code> and <code>os.cpus()<\/code> read details from the computer.<\/li>\n<\/ul>\n<p>Run it with <code>node hello.js<\/code>, then with <code>node hello.js YourName<\/code>. Congratulations, you have just run JavaScript outside the browser.<\/p>\n\n<h2 id=\"non-blocking\">See non-blocking code in action<\/h2>\n<p>Now let&#8217;s prove the restaurant idea with real code. Before you click Run, guess the order in which the five lines will print.<\/p>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: async-demo.js\">\n<input type=\"radio\" name=\"v2\" id=\"v2f1\" class=\"f1\" checked>\n<input type=\"checkbox\" id=\"v2r1\" class=\"r1\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">async-demo.js \u2014 node-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v2f1\" class=\"t1\"><b class=\"ic js\">JS<\/b>async-demo.js<\/label>\n<label for=\"v2r1\" class=\"run run1\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">node-part1 \u203a async-demo.js<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ async-demo.js \u2013 Node.js does not wait for slow work<\/span><\/span>\n<span class=\"l\"><span class=\"k\">import<\/span> { <span class=\"n\">readFile<\/span> } <span class=\"k\">from<\/span> <span class=\"s\">\"node:fs\/promises\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"1. Start\"<\/span>);<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nf\">setTimeout<\/span>(() =&gt; {<\/span>\n<span class=\"l\">  <span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"4. Timer finished (after 0 ms)\"<\/span>);<\/span>\n<span class=\"l\">}, <span class=\"m\">0<\/span>);<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nf\">readFile<\/span>(<span class=\"s\">\"package.json\"<\/span>, <span class=\"s\">\"utf8\"<\/span>).<span class=\"nf\">then<\/span>((<span class=\"n\">text<\/span>) =&gt; {<\/span>\n<span class=\"l\">  <span class=\"k\">const<\/span> <span class=\"n\">pkg<\/span> = <span class=\"nb\">JSON<\/span>.<span class=\"nf\">parse<\/span>(<span class=\"n\">text<\/span>);<\/span>\n<span class=\"l\">  <span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">`5. File read: project name is \"${<\/span><span class=\"n\">pkg<\/span>.<span class=\"n\">name<\/span><span class=\"s\">}\"`<\/span>);<\/span>\n<span class=\"l\">});<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"2. Asked for the timer and the file\"<\/span>);<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">\"3. Still running other code...\"<\/span>);<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output (Node.js 22)<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node async-demo.js\n1. Start\n2. Asked for the timer and the file\n3. Still running other code...\n4. Timer finished (after 0 ms)\n5. File read: project name is \"node-part1\"<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 16, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Make your guess, then click <strong>\u25b6 Run<\/strong>.<\/p>\n<p>Even with a delay of <code>0<\/code> ms, the timer message prints <strong>after<\/strong> lines 2 and 3. Here is why:<\/p>\n<ol>\n<li>Node.js runs all the normal code from top to bottom first (lines 1, 2, 3).<\/li>\n<li><code>setTimeout<\/code> and <code>readFile<\/code> do not stop the program. They hand the work to the background and register a callback.<\/li>\n<li>Only when the main code is finished does the event loop run the waiting callbacks: first the timer, then the file result once the disk has answered.<\/li>\n<\/ol>\n<div class=\"dd-tip\"><strong>Remember:<\/strong> in Node.js, \u201cI asked for it\u201d and \u201cI got it\u201d are two different moments. Every database query and API call you write later works this way. Part 5 covers callbacks, promises and <code>async\/await<\/code> in detail.<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"first-server\">Build your first web server with Node.js<\/h2>\n<p>This is where Node.js shines. With the built-in <code>node:http<\/code> module you can build a working web server in about 20 lines, with <strong>no npm packages at all<\/strong>. Our server answers three kinds of requests: the home page <code>\/<\/code>, a small JSON API at <code>\/api\/time<\/code>, and a 404 page for everything else.<\/p>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: server.js, client.js\">\n<input type=\"radio\" name=\"v3\" id=\"v3f1\" class=\"f1\" checked>\n<input type=\"radio\" name=\"v3\" id=\"v3f2\" class=\"f2\">\n<input type=\"checkbox\" id=\"v3r1\" class=\"r1\">\n<input type=\"checkbox\" id=\"v3r2\" class=\"r2\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">2 files \u2014 node-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v3f1\" class=\"t1\"><b class=\"ic js\">JS<\/b>server.js<\/label>\n<label for=\"v3f2\" class=\"t2\"><b class=\"ic js\">JS<\/b>client.js<\/label>\n<label for=\"v3r1\" class=\"run run1\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<label for=\"v3r2\" class=\"run run2\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">node-part1 \u203a server.js<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ server.js \u2013 a tiny web server with no packages at all<\/span><\/span>\n<span class=\"l\"><span class=\"k\">import<\/span> { <span class=\"n\">createServer<\/span> } <span class=\"k\">from<\/span> <span class=\"s\">\"node:http\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">PORT<\/span> = <span class=\"nb\">process<\/span>.<span class=\"n\">env<\/span>.<span class=\"n\">PORT<\/span> || <span class=\"m\">3000<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">server<\/span> = <span class=\"nf\">createServer<\/span>((<span class=\"n\">req<\/span>, <span class=\"n\">res<\/span>) =&gt; {<\/span>\n<span class=\"l\">  <span class=\"k\">if<\/span> (<span class=\"n\">req<\/span>.<span class=\"n\">url<\/span> === <span class=\"s\">\"\/\"<\/span>) {<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">writeHead<\/span>(<span class=\"m\">200<\/span>, { <span class=\"s\">\"Content-Type\"<\/span>: <span class=\"s\">\"text\/plain; charset=utf-8\"<\/span> });<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">end<\/span>(<span class=\"s\">\"Hello from Node.js!\\n\"<\/span>);<\/span>\n<span class=\"l\">  } <span class=\"k\">else<\/span> <span class=\"k\">if<\/span> (<span class=\"n\">req<\/span>.<span class=\"n\">url<\/span> === <span class=\"s\">\"\/api\/time\"<\/span>) {<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">writeHead<\/span>(<span class=\"m\">200<\/span>, { <span class=\"s\">\"Content-Type\"<\/span>: <span class=\"s\">\"application\/json\"<\/span> });<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">end<\/span>(<span class=\"nb\">JSON<\/span>.<span class=\"nf\">stringify<\/span>({ <span class=\"n\">time<\/span>: new <span class=\"nb\">Date<\/span>().<span class=\"nf\">toISOString<\/span>() }));<\/span>\n<span class=\"l\">  } <span class=\"k\">else<\/span> {<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">writeHead<\/span>(<span class=\"m\">404<\/span>, { <span class=\"s\">\"Content-Type\"<\/span>: <span class=\"s\">\"text\/plain\"<\/span> });<\/span>\n<span class=\"l\">    <span class=\"n\">res<\/span>.<span class=\"nf\">end<\/span>(<span class=\"s\">\"Page not found\\n\"<\/span>);<\/span>\n<span class=\"l\">  }<\/span>\n<span class=\"l\">});<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">server<\/span>.<span class=\"nf\">listen<\/span>(<span class=\"n\">PORT<\/span>, () =&gt; {<\/span>\n<span class=\"l\">  <span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"s\">`Server running at http:\/\/localhost:${<\/span><span class=\"n\">PORT<\/span><span class=\"s\">}\/`<\/span>);<\/span>\n<span class=\"l\">});<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output \u2013 leave it running<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node server.js\nServer running at http:\/\/localhost:3000\/<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 21, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<div class=\"dd-vsc-pane p2\">\n<div class=\"dd-vsc-crumbs\">node-part1 \u203a client.js<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ client.js \u2013 call our server with the built-in fetch()<\/span><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">base<\/span> = <span class=\"s\">\"http:\/\/localhost:3000\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">home<\/span> = <span class=\"k\">await<\/span> <span class=\"nf\">fetch<\/span>(<span class=\"n\">base<\/span> + <span class=\"s\">\"\/\"<\/span>);<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"n\">home<\/span>.<span class=\"n\">status<\/span>, (<span class=\"k\">await<\/span> <span class=\"n\">home<\/span>.<span class=\"nf\">text<\/span>()).<span class=\"nf\">trim<\/span>());<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">api<\/span> = <span class=\"k\">await<\/span> <span class=\"nf\">fetch<\/span>(<span class=\"n\">base<\/span> + <span class=\"s\">\"\/api\/time\"<\/span>);<\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">data<\/span> = <span class=\"k\">await<\/span> <span class=\"n\">api<\/span>.<span class=\"nf\">json<\/span>();<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"n\">api<\/span>.<span class=\"n\">status<\/span>, <span class=\"n\">data<\/span>);<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">missing<\/span> = <span class=\"k\">await<\/span> <span class=\"nf\">fetch<\/span>(<span class=\"n\">base<\/span> + <span class=\"s\">\"\/nope\"<\/span>);<\/span>\n<span class=\"l\"><span class=\"nb\">console<\/span>.<span class=\"nf\">log<\/span>(<span class=\"n\">missing<\/span>.<span class=\"n\">status<\/span>, (<span class=\"k\">await<\/span> <span class=\"n\">missing<\/span>.<span class=\"nf\">text<\/span>()).<span class=\"nf\">trim<\/span>());<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output (second terminal)<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node client.js\n200 Hello from Node.js!\n200 { time: '2026-10-23T13:54:05.642Z' }\n404 Page not found<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 12, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Click the <strong>server.js<\/strong> and <strong>client.js<\/strong> tabs, then <strong>\u25b6 Run<\/strong> on each. Start the server first and keep it running; run the client in a second terminal.<\/p>\n<p>How the server works:<\/p>\n<ul>\n<li><code>createServer()<\/code> takes a function that runs <strong>for every request<\/strong>. It receives <code>req<\/code> (the request: URL, method, headers) and <code>res<\/code> (the response you send back).<\/li>\n<li><code>res.writeHead(200, ...)<\/code> sets the status code and headers. <code>200<\/code> means OK, <code>404<\/code> means not found. The <code>Content-Type<\/code> header tells the browser what kind of data is coming.<\/li>\n<li><code>res.end(...)<\/code> sends the body and finishes the response. For JSON we turn an object into text with <code>JSON.stringify<\/code>.<\/li>\n<li><code>server.listen(PORT)<\/code> starts listening. <code>process.env.PORT<\/code> lets a hosting platform choose the port, with <code>3000<\/code> as the local default.<\/li>\n<\/ul>\n<p>Open <code>http:\/\/localhost:3000\/<\/code> and <code>http:\/\/localhost:3000\/api\/time<\/code> in your browser too. In <code>client.js<\/code> we used the built-in <code>fetch()<\/code> and <strong>top-level <code>await<\/code><\/strong> (allowed in ES modules) to test the server from code. You can also test with <code>curl http:\/\/localhost:3000\/<\/code>.<\/p>\n<div class=\"dd-note\"><strong>Is this how real apps are built?<\/strong> Real projects usually use a framework such as Express or Fastify for routing, middleware and validation. But every one of them is built on this same <code>http<\/code> module, so understanding it now makes those frameworks easy later (Part 11 starts Express).<\/div>\n\n<h2 id=\"package-json\">package.json, npm scripts and &#8211;watch<\/h2>\n<p>Every Node.js project has a <code>package.json<\/code> file in its root folder. It stores the project name, version, the packages it needs and handy <strong>scripts<\/strong>. Create one with <code>npm init -y<\/code> (<code>-y<\/code> means \u201cyes to all defaults\u201d):<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: node-part1 \u2014 bash\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">node-part1 \u2014 bash<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Create a folder and a package.json in one go<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> mkdir node-part1<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> cd node-part1<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> npm init -y<\/span>\n<span class=\"l\">Wrote to \/home\/you\/node-part1\/package.json:<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\">{<\/span>\n<span class=\"l\">  \"name\": \"node-part1\",<\/span>\n<span class=\"l\">  \"version\": \"1.0.0\",<\/span>\n<span class=\"l\">  \"description\": \"\",<\/span>\n<span class=\"l\">  \"main\": \"index.js\",<\/span>\n<span class=\"l\">  \"scripts\": {<\/span>\n<span class=\"l\">    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"<\/span>\n<span class=\"l\">  },<\/span>\n<span class=\"l\">  \"keywords\": [],<\/span>\n<span class=\"l\">  \"author\": \"\",<\/span>\n<span class=\"l\">  \"license\": \"ISC\"<\/span>\n<span class=\"l\">}<\/span><\/code><\/pre>\n<\/div>\n<p>Now edit it to look like this. We add <code>\"type\": \"module\"<\/code> so <code>import<\/code> works in every <code>.js<\/code> file, and two scripts: <code>start<\/code> for normal runs and <code>dev<\/code> for development.<\/p>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: package.json\">\n<input type=\"radio\" name=\"v4\" id=\"v4f1\" class=\"f1\" checked>\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">package.json \u2014 node-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v4f1\" class=\"t1\"><b class=\"ic js\">{ }<\/b>package.json<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">node-part1 \u203a package.json<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\">{<\/span>\n<span class=\"l\">  <span class=\"s\">\"name\"<\/span>: <span class=\"s\">\"node-part1\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"s\">\"version\"<\/span>: <span class=\"s\">\"1.0.0\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"s\">\"type\"<\/span>: <span class=\"s\">\"module\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"s\">\"scripts\"<\/span>: {<\/span>\n<span class=\"l\">    <span class=\"s\">\"start\"<\/span>: <span class=\"s\">\"node server.js\"<\/span>,<\/span>\n<span class=\"l\">    <span class=\"s\">\"dev\"<\/span>: <span class=\"s\">\"node --watch server.js\"<\/span><\/span>\n<span class=\"l\">  }<\/span>\n<span class=\"l\">}<\/span><\/code><\/pre>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 9, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JSON<\/span><\/div>\n<\/div>\n<\/div>\n<p>Run the scripts from the terminal:<\/p>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: node-part1 \u2014 bash\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">node-part1 \u2014 bash<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># Run a script from package.json<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> npm run dev<\/span>\n<span class=\"l\"><span class=\"c\"># Or use Node's own faster script runner (Node.js 22+)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node --run dev<\/span>\n<span class=\"l\"><span class=\"c\"># Restart automatically when you save a file (no nodemon needed)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> node --watch server.js<\/span>\n<span class=\"l\"><span class=\"c\"># Stop the server<\/span><\/span>\n<span class=\"l\"><span class=\"c\"># press Ctrl + C<\/span><\/span><\/code><\/pre>\n<\/div>\n<ul>\n<li><code>npm run dev<\/code> runs the <code>dev<\/code> script. <code>npm start<\/code> is a short form for the <code>start<\/code> script.<\/li>\n<li><code>node --run dev<\/code> does the same but starts faster because it skips npm (available in Node.js 22 and newer).<\/li>\n<li><code>node --watch<\/code> restarts the server every time you save a file. You no longer need the old <code>nodemon<\/code> package for this.<\/li>\n<\/ul>\n<div class=\"dd-tip\"><strong>Tip:<\/strong> commit <code>package.json<\/code> (and later <code>package-lock.json<\/code>) to Git, but never the <code>node_modules<\/code> folder. Add <code>node_modules\/<\/code> to your <code>.gitignore<\/code>. Part 3 covers npm in depth.<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"common-errors\">Common Node.js errors and fixes<\/h2>\n<p>Every beginner hits these. Bookmark this table; you will see these messages again.<\/p>\n<div class=\"dd-tablewrap\"><table>\n<thead><tr><th>Error message<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead>\n<tbody>\n<tr><td><code>'node' is not recognized<\/code> \/ <code>command not found: node<\/code><\/td><td>Node.js is not installed, or the terminal was open before installing so PATH was not refreshed.<\/td><td>Install the LTS version, then close and reopen the terminal. With nvm, run <code>nvm use --lts<\/code>.<\/td><\/tr>\n<tr><td><code>SyntaxError: Cannot use import statement outside a module<\/code><\/td><td>You used <code>import<\/code> in a <code>.js<\/code> file, but the project is treated as CommonJS.<\/td><td>Add <code>\"type\": \"module\"<\/code> to <code>package.json<\/code>, or rename the file to <code>.mjs<\/code>.<\/td><\/tr>\n<tr><td><code>ReferenceError: require is not defined in ES module scope<\/code><\/td><td>You used old CommonJS <code>require()<\/code> inside an ES module.<\/td><td>Use <code>import fs from \"node:fs\"<\/code> instead (or rename the file to <code>.cjs<\/code>).<\/td><\/tr>\n<tr><td><code>ReferenceError: document is not defined<\/code><\/td><td>Browser-only objects like <code>document<\/code>, <code>window<\/code> and <code>localStorage<\/code> do not exist in Node.js.<\/td><td>Keep DOM code in the browser. In Node.js use modules like <code>fs<\/code>, <code>http<\/code> and <code>os<\/code>.<\/td><\/tr>\n<tr><td><code>Error: listen EADDRINUSE: address already in use :::3000<\/code><\/td><td>Another program (often your old server) is already using port 3000.<\/td><td>Stop the old server with <code>Ctrl + C<\/code>, or start on another port: <code>PORT=4000 node server.js<\/code>.<\/td><\/tr>\n<tr><td><code>Error [ERR_MODULE_NOT_FOUND]: Cannot find module<\/code><\/td><td>Wrong file path, missing <code>.js<\/code> extension in an ES module import, or the package is not installed.<\/td><td>Check the path, write <code>.\/utils.js<\/code> (with the extension), and run <code>npm install<\/code>.<\/td><\/tr>\n<\/tbody><\/table><\/div>\n\n<h2 id=\"best-practices\">Best practices from day one<\/h2>\n<ul>\n<li><strong>Use the LTS version<\/strong> and a version manager (nvm, fnm or Volta) so each project can use the version it needs.<\/li>\n<li><strong>Use ES modules<\/strong> (<code>import<\/code>\/<code>export<\/code> with <code>\"type\": \"module\"<\/code>). This is the modern standard and matches browser JavaScript.<\/li>\n<li><strong>Write the <code>node:<\/code> prefix<\/strong> for built-in modules (<code>node:fs<\/code>, <code>node:http<\/code>). It is clearer and avoids confusion with npm packages.<\/li>\n<li><strong>Never block the event loop.<\/strong> Prefer the async versions of APIs (<code>fs\/promises<\/code> instead of <code>readFileSync<\/code>) inside servers.<\/li>\n<li><strong>Read config from environment variables<\/strong> (like <code>process.env.PORT<\/code>) instead of hard-coding ports, passwords or API keys.<\/li>\n<li><strong>Use <code>node --watch<\/code> in development<\/strong> and a plain <code>node<\/code> command in production.<\/li>\n<li><strong>Keep secrets out of Git.<\/strong> No API keys in code files. We will set up <code>.env<\/code> files properly in Part 15.<\/li>\n<\/ul>\n\n<h2 id=\"practice\">Practice task<\/h2>\n<div class=\"dd-note\">\n<p><strong>Build a tiny \u201cAbout me\u201d API.<\/strong> Use only what you learned in this part.<\/p>\n<ol>\n<li>Create a new folder, run <code>npm init -y<\/code> and add <code>\"type\": \"module\"<\/code> plus a <code>dev<\/code> script that uses <code>node --watch<\/code>.<\/li>\n<li>Copy <code>server.js<\/code> and add a new route <code>\/api\/me<\/code> that returns JSON with your <code>name<\/code>, <code>city<\/code> and <code>skills<\/code> (an array).<\/li>\n<li>Add a route <code>\/api\/system<\/code> that returns the Node.js version (<code>process.version<\/code>) and the number of CPU cores (<code>os.cpus().length<\/code>).<\/li>\n<li>Make the 404 response JSON too: <code>{ \"error\": \"Not found\", \"path\": req.url }<\/code>.<\/li>\n<li><em>Bonus:<\/em> change <code>client.js<\/code> to call all your routes and print the results. Then start the server on port 4000 using <code>PORT=4000 npm run dev<\/code>.<\/li>\n<\/ol>\n<\/div>\n\n<h2 id=\"faq\">Frequently asked questions<\/h2>\n<details><summary>Is Node.js a programming language?<\/summary><p>No. The language is JavaScript. Node.js is a runtime, the program that runs JavaScript outside the browser and gives it access to files, the network and the operating system.<\/p><\/details>\n<details><summary>Is Node.js frontend or backend?<\/summary><p>Mainly backend: APIs, servers, databases and background jobs. But frontend developers also use Node.js every day, because tools like Vite, Next.js, ESLint and TypeScript run on it.<\/p><\/details>\n<details><summary>Is Node.js single-threaded?<\/summary><p>Your JavaScript runs on one main thread, but Node.js itself uses extra threads (through libuv) for things like file access, and you can create worker threads for heavy CPU work. That is why one Node.js process can serve many users at once.<\/p><\/details>\n<details><summary>Which Node.js version should I install?<\/summary><p>The latest LTS version shown on nodejs.org. Use a version manager like nvm so you can switch versions per project. All code in this series works on Node.js 22, 24 and 26.<\/p><\/details>\n<details><summary>Node.js vs Python or Java for backend: which is better?<\/summary><p>All three are great. Node.js is a strong choice for APIs and real-time apps, and it lets you use one language (JavaScript or TypeScript) on both the frontend and the backend. Python shines in data and AI work, and Java is popular in large enterprise systems.<\/p><\/details>\n<details><summary>Is Node.js still worth learning?<\/summary><p>Yes. It is one of the most used backend technologies, it has the largest package ecosystem (npm), and it appears in a huge number of backend and full-stack job posts in India and abroad. Preparing for interviews? See our <a href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/\">Node.js interview questions<\/a>.<\/p><\/details>\n\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>You now know <strong>what Node.js is<\/strong>: a JavaScript runtime built on V8 that runs your code outside the browser and adds files, servers and operating-system access. You learned how it differs from browser JavaScript, how the event loop lets one thread serve many users without waiting, and what you can build with it. You installed Node.js, tried the REPL, wrote your first scripts, saw non-blocking code with your own eyes, built a web server with zero packages, and set up <code>package.json<\/code> with scripts and <code>--watch<\/code>.<\/p>\n<p>Want to see where this road leads? Our <a href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/10\/docker-compose-tutorial\/\">Docker Compose tutorial<\/a> runs a Node.js app with PostgreSQL and Redis, and the <a href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/06\/github-actions-ci-cd-nodejs\/\">GitHub Actions CI\/CD guide for Node.js<\/a> shows how to test and deploy it automatically.<\/p>\n\n<div class=\"dd-next\"><strong>Next part \u2013 Node.js Part 2: Modules in Node.js: ES Modules, CommonJS and import\/export.<\/strong> We will split code into files, learn the difference between <code>import<\/code> and <code>require()<\/code>, named vs default exports, and how Node.js finds your modules.<\/div>\n\n<div class=\"dd-cta\">\n<h3>New posts every day on DevDojo<\/h3>\n<p>Follow the full <strong>Node.js series<\/strong> \u2013 30 parts from \u201cwhat is Node.js\u201d to building and deploying a production-ready API. Bookmark <a href=\"https:\/\/devdojo.co.in\/\">devdojo.co.in<\/a> and tell us in the comments what you want to build with Node.js.<\/p>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.<\/p>\n","protected":false},"author":1,"featured_media":234,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[56,82,83,43,127,126],"class_list":["post-235","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-backend","category-nodejs","tag-backend-development","tag-event-loop","tag-javascript","tag-node-js","tag-node-js-for-beginners","tag-series-node-js"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Lokendra\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DevDojo - Empowering Developers\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"What Is Node.js? Build Your First Node.js App\" \/>\n\t\t<meta property=\"og:description\" content=\"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-10-23T14:03:23+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-10-23T14:03:24+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"What Is Node.js? Build Your First Node.js App\" \/>\n\t\t<meta name=\"twitter:description\" content=\"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#blogposting\",\"name\":\"What Is Node.js? Build Your First Node.js App | DevDojo\",\"headline\":\"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App\",\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/nodejs-series-part-1-what-is-nodejs.jpg\",\"width\":1200,\"height\":630,\"caption\":\"Node.js Part 1 banner: What Is Node.js? Your First Node.js App, with the event loop handling files, network and database\"},\"datePublished\":\"2026-10-23T14:03:23+00:00\",\"dateModified\":\"2026-10-23T14:03:24+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#webpage\"},\"articleSection\":\"Backend, NodeJS, Backend Development, Event Loop, JavaScript, Node.js, Node.js for Beginners, Series: Node.js\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"name\":\"Backend\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"position\":2,\"name\":\"Backend\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"name\":\"NodeJS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"position\":3,\"name\":\"NodeJS\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#listItem\",\"name\":\"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"name\":\"Backend\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#listItem\",\"position\":4,\"name\":\"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"name\":\"NodeJS\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/\",\"name\":\"Lokendra\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Lokendra\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#webpage\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/\",\"name\":\"What Is Node.js? Build Your First Node.js App | DevDojo\",\"description\":\"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/nodejs-series-part-1-what-is-nodejs.jpg\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#mainImage\",\"width\":1200,\"height\":630,\"caption\":\"Node.js Part 1 banner: What Is Node.js? Your First Node.js App, with the event loop handling files, network and database\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/23\\\/nodejs-series-part-1-what-is-nodejs\\\/#mainImage\"},\"datePublished\":\"2026-10-23T14:03:23+00:00\",\"dateModified\":\"2026-10-23T14:03:24+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"What Is Node.js? Build Your First Node.js App | DevDojo","description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.","canonical_url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#blogposting","name":"What Is Node.js? Build Your First Node.js App | DevDojo","headline":"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App","author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/nodejs-series-part-1-what-is-nodejs.jpg","width":1200,"height":630,"caption":"Node.js Part 1 banner: What Is Node.js? Your First Node.js App, with the event loop handling files, network and database"},"datePublished":"2026-10-23T14:03:23+00:00","dateModified":"2026-10-23T14:03:24+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#webpage"},"isPartOf":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#webpage"},"articleSection":"Backend, NodeJS, Backend Development, Event Loop, JavaScript, Node.js, Node.js for Beginners, Series: Node.js"},{"@type":"BreadcrumbList","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","position":1,"name":"Home","item":"https:\/\/devdojo.co.in\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","name":"Backend"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","position":2,"name":"Backend","item":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","name":"NodeJS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","position":3,"name":"NodeJS","item":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#listItem","name":"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App"},"previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","name":"Backend"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#listItem","position":4,"name":"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App","previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","name":"NodeJS"}}]},{"@type":"Organization","@id":"https:\/\/devdojo.co.in\/#organization","name":"DevDojo","description":"Empowering Developers","url":"https:\/\/devdojo.co.in\/"},{"@type":"Person","@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author","url":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/","name":"Lokendra","image":{"@type":"ImageObject","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g","width":96,"height":96,"caption":"Lokendra"}},{"@type":"WebPage","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#webpage","url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/","name":"What Is Node.js? Build Your First Node.js App | DevDojo","description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/devdojo.co.in\/#website"},"breadcrumb":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#breadcrumblist"},"author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"creator":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/nodejs-series-part-1-what-is-nodejs.jpg","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#mainImage","width":1200,"height":630,"caption":"Node.js Part 1 banner: What Is Node.js? Your First Node.js App, with the event loop handling files, network and database"},"primaryImageOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/#mainImage"},"datePublished":"2026-10-23T14:03:23+00:00","dateModified":"2026-10-23T14:03:24+00:00"},{"@type":"WebSite","@id":"https:\/\/devdojo.co.in\/#website","url":"https:\/\/devdojo.co.in\/","name":"DevDojo","description":"Empowering Developers","inLanguage":"en-US","publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"}}]},"og:locale":"en_US","og:site_name":"DevDojo - Empowering Developers","og:type":"article","og:title":"What Is Node.js? Build Your First Node.js App","og:description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.","og:url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/","article:published_time":"2026-10-23T14:03:23+00:00","article:modified_time":"2026-10-23T14:03:24+00:00","twitter:card":"summary_large_image","twitter:title":"What Is Node.js? Build Your First Node.js App","twitter:description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step."},"aioseo_meta_data":{"post_id":"235","title":"What Is Node.js? Build Your First Node.js App | DevDojo","description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.","keywords":null,"keyphrases":{"focus":{"keyphrase":"what is Node.js","score":85},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":"What Is Node.js? Build Your First Node.js App","og_description":"What is Node.js? Learn how Node.js runs JavaScript on the server, how the event loop works, and build your first Node.js app and web server step by step.","og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":0,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-10-23 14:00:11","updated":"2026-10-23 14:26:18","focus_keyword":"what is Node.js","additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/index.php\/category\/backend\/\" title=\"Backend\">Backend<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/\" title=\"NodeJS\">NodeJS<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tNode.js Part 1: What Is Node.js and How to Build Your First Node.js App\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/devdojo.co.in\/"},{"label":"Backend","link":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/"},{"label":"NodeJS","link":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/"},{"label":"Node.js Part 1: What Is Node.js and How to Build Your First Node.js App","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/23\/nodejs-series-part-1-what-is-nodejs\/"}],"_links":{"self":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":1,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":236,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/235\/revisions\/236"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media\/234"}],"wp:attachment":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}