3 homepage: https://nodejs.org
5 Node.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
8 To update or switch versions, run `webi node@<tag>`. \
9 (you can use `@lts` for long-term support, `@beta` for pre-releases, or `@x.y.z`
10 for a specific version)
14 > Node is great for simple, snappy HTTP(S) servers, and for stitching APIs
15 > together with minimal fuss or muss.
17 Installing node via webi will:
19 - pick a compatible version from the
20 [Node Releases API](https://nodejs.org/dist/index.tab)
21 - download and unpack to `$HOME/.local/opt/node/`
22 - update your `PATH` in `$HOME/.config/envman/PATH.env`
23 - run `npm config set scripts-prepend-node-path=true`
24 - (prevents conflicts with other installed node versions)
25 - absolutely leave system file permissions alone
26 - (no dreaded `sudo npm` permission errors)
31 node -e 'console.log("Hello, World!")'
35 ### A Simple Web Server
40 var http = require('http');
41 var app = function (req, res) {
42 res.end('Hello, World!');
44 http.createServer(app).listen(8080, function () {
45 console.info('Listening on', this.address());
53 ### Generate a Secure Random Key
55 This generates a hex-encoded 128-bit random key.
58 node -p 'crypto.randomBytes(16).toString("hex")'
61 This generates a url-safe base64 256-bit random key.
64 node -p 'crypto.randomBytes(32).toString("base64")
65 .replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")'
74 npm install --save express
82 var express = require('express');
85 app.use('/', function (req, res, next) {
86 res.end('Hello, World!');
97 var http = require('http');
98 var app = require('./app.js');
100 http.createServer(app).listen(8080, function () {
101 console.info('Listening on', this.address());