3 homepage: https://nodejs.org
5 Node.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
8 ## Updating and Switch versions
14 Use `@lts` for long-term support and the `@beta` tag for pre-releases, or
15 `@x.y.z` for a specific version.
19 > Node is great for simple, snappy HTTP(S) servers, and for stitching APIs
20 > together with minimal fuss or muss.
22 Installing node via webi will:
24 - pick a compatible version from the
25 [Node Releases API](https://nodejs.org/dist/index.tab)
26 - download and unpack to `$HOME/.local/opt/node/`
27 - update your `PATH` in `$HOME/.config/envman/PATH.env`
28 - run `npm config set scripts-prepend-node-path=true`
29 - (prevents conflicts with other installed node versions)
30 - absolutely leave system file permissions alone
31 - (no dreaded `sudo npm` permission errors)
36 node -e 'console.log("Hello, World!")'
40 ### A Simple Web Server
45 var http = require('http');
46 var app = function (req, res) {
47 res.end('Hello, World!');
49 http.createServer(app).listen(8080, function () {
50 console.info('Listening on', this.address());
58 ### Generate a Secure Random Key
60 This generates a hex-encoded 128-bit random key.
63 node -p 'crypto.randomBytes(16).toString("hex")'
66 This generates a url-safe base64 256-bit random key.
69 node -p 'crypto.randomBytes(32).toString("base64")
70 .replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")'
79 npm install --save express
87 var express = require('express');
90 app.use('/', function (req, res, next) {
91 res.end('Hello, World!');
102 var http = require('http');
103 var app = require('./app.js');
105 http.createServer(app).listen(8080, function () {
106 console.info('Listening on', this.address());