Node.js v10.0.0-v8-canary2018012359f60bab11 Documentation

Table of Contents


node [options] [V8 options] [script.js | -e "script" | - ] [arguments]

Please see the Command Line Options document for information about different options and ways to run scripts with Node.js.


An example of a web server written with Node.js which responds with 'Hello World':

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);

To run the server, put the code into a file called example.js and execute it with Node.js:

$ node example.js
Server running at

Many of the examples in the documentation can be run similarly.