Node.js Tutorial
Node.js lets you run JavaScript outside the browser, on your computer or on a server. With it you can build web servers, APIs, command-line tools and real-time apps such as chat.
Before Node.js, JavaScript only ran inside web pages. Now one language can power both the front end and the back end, which is why Node.js is a key skill for full stack developers. Companies like Netflix, PayPal and LinkedIn use it, and so do many Pakistani software houses and freelancers.
A First Look at Node.js
Save this as hello.js:
Example
const name = "Ali";
const hour = new Date().getHours();
const greeting = hour < 12 ? "Good morning" : "Good evening";
console.log(`${greeting}, ${name}! Node.js is running.`);Run it in a terminal:
Example
node hello.jsGood evening, Ali! Node.js is running.
There is no browser and no HTML. Node.js runs the file and prints the result in the terminal.
What You Will Learn
- What Node.js is and how to install and run it
- Modules: CommonJS and ES modules
- npm and the
package.jsonfile - Asynchronous code with callbacks, promises and
async/await - Working with files, events and HTTP servers
- Building a small REST API with Express
Exercises and Quiz
Every lesson ends with an exercise, and the last lesson has a quiz on the whole tutorial.
Exercise
What does Node.js let you do?
What to Learn After Node.js
You should know JavaScript before starting. After Node.js, connect your server to a database, and build a front end with React or Vue.
Want to become a full stack developer with a teacher's help? The Workownix Full Stack Web Development course covers Node.js, Express, databases and React, online or at our institute in Orangi Town, Karachi.
