Getting Started with Node.js

You've probably already heard that Node excels at building scalable servers. But what really sets Node apart is that it does so while still being an incredibly easy platform to get started with. In fact, let's do that right now and begin exploring Node's capabilities. In the editor below you'll a simple "Hello World" app — go ahead and change the code, it's running live and you'll see the updates automatically on the right!

simple.js

const http = require("http");
// Create a server that always returns "Hello World!".
const server = http.createServer((req, res) => {
res.end("Hello World!");
});
// Start the server
server.listen(8000, () => {
console.log("Server started on port 8000!");
});

Using Packages

Another huge benefit of developing with Node is that it has the largest and most active package ecosystem, npm. With over 700,000 packages, chances are someone's already implemented the peices you need for your project! Let's write a small utility that searches animated gifs and you'll see how it feels like assembling the right parts. Just as before, feel free to experiment and require other packages -- all 700,000 are already preinstalled in this tutorial.

image-search.js

const cheerio = require("cheerio");
const imageRender = require("image-render");
const got = require("got");
const app = require("express")();
app.get("/", async (req, res) =>
{
const keywords = encodeURIComponent(req.query.keywords);
const URL = `http://images.google.com/search?tbm=isch&q=${keywords}`;
const HTML = (await got(URL)).body;
const $ = cheerio.load(HTML);
const src = $("#ires td a img").attr("src");
res.send(imageRender(src));
});
app.listen(3000);

Node.js Microservices

You've probably already heard that Node excels at building scalable servers. But what really sets Node apart is that it does so while still being an incredibly easy platform to get started with. In fact, let's do that right now and begin exploring Node's capabilities. In the editor below you'll a simple "Hello World" app — go ahead and change the code, it's running live and you'll see the updates automatically on the right!

simple.js

const http = require("http");
// Create a server that always returns "Hello World!".
const server = http.createServer((req, res) => {
res.end("Hello World!");
});
// Start the server
server.listen(8000, () => {
console.log("Server started on port 8000!");
});

Terminal Applications

You've probably already heard that Node excels at building scalable servers. But what really sets Node apart is that it does so while still being an incredibly easy platform to get started with. In fact, let's do that right now and begin exploring Node's capabilities. In the editor below you'll a simple "Hello World" app — go ahead and change the code, it's running live and you'll see the updates automatically on the right!

simple.js

const http = require("http");
// Create a server that always returns "Hello World!".
const server = http.createServer((req, res) => {
res.end("Hello World!");
});
// Start the server
server.listen(8000, () => {
console.log("Server started on port 8000!");
});