Tsallaka zuwa abun ciki
Justice Tech School

Node.js Tutorial

Run JavaScript on the server to build APIs and tools.

Start learning Node.js
Getting started2 lessons
  1. 1Node.js IntroductionJavaScript outside the browser.
  2. 2Get StartedInstall and run your first file.
Basics34 lessons
  1. 3ModulesCommonJS and ES modules.
  2. 4npm and package.jsonUse other people's code.
  3. 5Globals and processprocess, __dirname and arguments.
  4. 6The console Objectconsole.log writes to standard output, console.error to standard error.
  5. 7Modern JavaScript in NodeNode supports modern JavaScript: let and const, arrow functions, destructuring, spread, te.
  6. 8The path Modulepath builds and parses file paths in a cross platform way.
  7. 9The os Moduleos tells you about the machine: platform, CPU count, memory and the temp folder.
  8. 10URL and URLSearchParamsThe global URL class parses addresses and URLSearchParams reads and builds query strings.
  9. 11The util Moduleutil.format builds strings, util.inspect prints objects deeply and util.promisify turns ca.
  10. 12BuffersA Buffer is a fixed size chunk of raw bytes.
  11. 13Timers and the Event Loop Orderprocess.nextTick runs before promises, which run before timers.
  12. 14Environment Variables and Argumentsprocess.env holds environment variables and process.argv holds command line arguments.
  13. 15Errors and Error CodesWrap risky code in try and catch.
  14. 16ES Modules and Dynamic ImportUse import and export in .mjs files or when package.json has type module.
  15. 17npm Scripts and VersionsScripts in package.json run with npm run name.
  16. 18Running Node.jsRun a file with node file.js.
  17. 19Variables and TypesNode runs JavaScript.
  18. 20Functions and ArrowsFunctions are values.
  19. 21Objects and JSONObjects hold data.
  20. 22CommonJS Modulesrequire loads a module and module.exports shares values.
  21. 23ES ModulesFiles ending in .mjs or with "type": "module" use import and export.
  22. 24Command Line Argumentsprocess.argv lists the arguments.
  23. 25The process Objectprocess has env, cwd, platform, pid, memoryUsage, uptime and exit.
  24. 26Environment Variablesprocess.env holds environment variables as strings.
  25. 27console Methodsconsole has log, error, warn, table, dir, group, time and assert.
  26. 28Template StringsBackticks allow ${} expressions and multi line text.
  27. 29Destructuring and SpreadPull values out of objects and arrays and copy or merge with spread.
  28. 30Array Methodsmap, filter, reduce, find, some, every, sort and flat are the daily tools.
  29. 31ClassesClasses have constructors and methods.
  30. 32Callbacks and Error FirstNode callbacks take (err, data).
  31. 33PromisesA promise stands for a future value.
  32. 34async and awaitasync functions return promises.
  33. 35The Event LoopSynchronous code runs first, then microtasks (promises), then timers.
  34. 36TimerssetTimeout, setInterval and setImmediate schedule work.
Files and events30 lessons
  1. 37File SystemRead and write files.
  2. 38EventsEventEmitter.
  3. 39Callbacks, Promises and async/awaitNon blocking code.
  4. 40Promises with fs/promisesfs/promises gives promise versions of the file functions, which work well with async and a.
  5. 41Folders and File Informationmkdir creates folders, readdir lists them, stat returns size and type, and rm removes file.
  6. 42Streams and pipelineStreams process data in chunks, so a huge file never needs to fit in memory.
  7. 43Reading Lines with readlinereadline reads a stream one line at a time.
  8. 44Running Other Programschild_process runs commands.
  9. 45Hashing and CryptoThe crypto module hashes data, signs messages with HMAC and makes random values.
  10. 46Compression with zlibzlib compresses and decompresses data with gzip or deflate.
  11. 47EventEmitter In Depthonce runs a listener a single time, off removes one, and the special error event throws if.
  12. 48Timers Promises and AbortControllertimers/promises gives awaitable delays.
  13. 49path Modulepath.join, resolve, basename, extname and dirname build and read file paths without string.
  14. 50Reading and Writing Filesfs.writeFileSync and readFileSync are simple for small scripts.
  15. 51fs.promisesfs/promises works with await and never blocks the event loop.
  16. 52Directoriesmkdir, readdir, stat, rm and cp manage folders.
  17. 53Checking Filesfs.existsSync tests a path.
  18. 54EventEmitterEventEmitter lets objects emit named events and listeners react.
  19. 55Error EventsAn emitter that emits "error" without a listener throws.
  20. 56BuffersBuffers hold raw bytes.
  21. 57StreamsStreams process data in chunks.
  22. 58pipeline and Transformstream.pipeline connects streams and handles errors and cleanup.
  23. 59readlinereadline reads input line by line.
  24. 60os Moduleos gives system info: platform, cpus, memory and the temp folder.
  25. 61URL and URLSearchParamsThe URL class parses addresses and URLSearchParams handles queries.
  26. 62util Moduleutil.promisify, format, inspect and types help with everyday work.
  27. 63cryptocrypto makes hashes, random values and UUIDs.
  28. 64child_processexecSync and spawn run other programs.
  29. 65zlibzlib compresses data with gzip and deflate.
  30. 66Worker Threadsworker_threads run JavaScript on another thread for heavy CPU work.
Web with Node33 lessons
  1. 67HTTP ServerThe built in http module.
  2. 68JSON and StreamsHandle data in pieces.
  3. 69HTTP Server and fetch TogetherNode 18 and newer include fetch.
  4. 70Routing by HandWithout a framework you read req.method and req.url and choose a handler.
  5. 71A JSON REST HandlerA REST API maps HTTP methods to actions: GET reads, POST creates, PUT updates and DELETE r.
  6. 72Headers and CookiesHeaders carry metadata.
  7. 73Configuration and dotenvKeep secrets and settings in environment variables.
  8. 74Rendering HTMLServers often build HTML from data.
  9. 75WebSockets and Server Sent EventsWebSockets keep a two way connection open for chat and live updates.
  10. 76A Basic HTTP Serverhttp.createServer handles requests.
  11. 77Routing by HandCheck req.method and req.url to decide what to send.
  12. 78fetch in NodeNode 18+ has fetch built in.
  13. 79Reading a Request BodyCollect chunks from the request stream, then parse them.
  14. 80HTTP Status Codes200 OK, 201 Created, 301 Redirect, 400 Bad Request, 401 Unauthorized, 404 Not Found and 50.
  15. 81Headers and CORSSet headers with setHeader.
  16. 82CookiesRead Cookie headers and send Set-Cookie.
  17. 83Serving Static FilesRead a file and send it with the right content type.
  18. 84Query StringsParse the query with URLSearchParams from req.url.
  19. 85A JSON APIReturn JSON with the right header and status codes.
  20. 86Express in One LookExpress wraps http with routing and middleware.
  21. 87Middleware IdeaMiddleware is a chain of functions where each can change the request or stop it.
  22. 88Configuration with dotenvKeep settings in .env and load them with dotenv or node --env-file.
  23. 89npm Commandsnpm init, install, run, update, outdated and ci manage packages.
  24. 90Semantic VersioningVersions are MAJOR.MINOR.PATCH.
  25. 91The Built in Test Runnernode:test and node:assert give you tests without extra packages.
  26. 92assert Moduleassert checks conditions and throws AssertionError when they fail.
  27. 93Error Types and Custom ErrorsError, TypeError and RangeError are built in.
  28. 94Uncaught Errorsprocess.on handles uncaughtException and unhandledRejection.
  29. 95Modern GlobalsNode has fetch, URL, AbortController, structuredClone, TextEncoder and more as globals.
  30. 96Cancelling with AbortControllerAbortController cancels fetches, timers and streams that accept a signal.
  31. 97Practice: Group and CountUse reduce to build a frequency map.
  32. 98Practice: A Tiny CLIParse arguments and print results.
  33. 99Practice: Log File SummaryRead a file, split lines and count levels.
Advanced Node.jsPremium13 lessons
  1. 100Express and REST APIsThe most popular framework.
  2. 101Testing with node:testBuilt in test runner.
  3. 102Worker Threads and PerformanceUse more than one core.
  4. 103Security and DeploymentShip safely.
  5. 104Transform StreamsA Transform stream changes data as it flows through.
  6. 105AsyncLocalStorageAsyncLocalStorage keeps context, such as a request id, across async calls without passing .
  7. 106Measuring Performanceperformance.now measures elapsed time.
  8. 107Assertions with node:assertassert checks values and throws on failure.
  9. 108Built in SQLiteNode 22.5+ includes node:sqlite so small apps need no database server.
  10. 109Modern GlobalsNode includes web style globals: fetch, structuredClone, TextEncoder, AbortSignal.timeout,.
  11. 110Cluster and Process ManagersNode runs on one thread, so cluster or a process manager such as PM2 starts one worker per.
  12. 111Express MiddlewareMiddleware are functions that run in order: logging, parsing, authentication, then routes .
  13. 112TypeScript with NodeNode 22.6+ can run TypeScript files that only use erasable syntax with --experimental-stri.
Node.js in practicePremium7 lessons
  1. 113Project StructureGroup code by feature, keep configuration in one place, and separate routes from business .
  2. 114Handling Async ErrorsRejected promises with no catch can crash the process.
  3. 115Graceful ShutdownOn SIGTERM stop accepting connections, finish active requests, close databases, then exit.
  4. 116LoggingUse a structured logger such as pino that writes JSON lines, adds timestamps and levels, a.
  5. 117Security ChecklistValidate input, use helmet for headers, rate limit, keep dependencies updated with npm aud.
  6. 118Docker and DeploymentUse a small node image, copy package files first for layer caching, install only productio.
  7. 119Node.js Best PracticesPrefer async over blocking calls, handle every error, keep functions small, pin Node with .
Next steps1 lessons
  1. 120What Next?Where to go after the basics.