{ "source": "doc/api/synopsis.md", "miscs": [ { "textRaw": "Usage", "name": "Usage", "type": "misc", "desc": "
node [options] [v8 options] [script.js | -e "script"] [arguments]
Please see the Command Line Options document for information about\ndifferent options and ways to run scripts with Node.js.
\nAn example of a web server written with Node.js which responds with\n'Hello World'
:
const http = require('http');\n\nconst hostname = '127.0.0.1';\nconst port = 3000;\n\nconst server = http.createServer((req, res) => {\n res.statusCode = 200;\n res.setHeader('Content-Type', 'text/plain');\n res.end('Hello World\\n');\n});\n\nserver.listen(port, hostname, () => {\n console.log(`Server running at http://${hostname}:${port}/`);\n});\n
\nTo run the server, put the code into a file called example.js
and execute\nit with Node.js:
$ node example.js\nServer running at http://127.0.0.1:3000/\n
\nAll of the examples in the documentation can be run similarly.
\n" } ] }