X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=node%2Fnode.bash;h=cac1272bca3cb08d2ca52abc448249c0474b1526;hb=77be4eb172eb0707be3f653189c10738e6090400;hp=13ce55821e2812d0bd242a025547b1db009976d9;hpb=5bacfd3c1724a966f12c5f699d7025cf8ee571fc;p=webi-installers%2F.git diff --git a/node/node.bash b/node/node.bash index 13ce558..cac1272 100644 --- a/node/node.bash +++ b/node/node.bash @@ -5,6 +5,48 @@ # tagline: JavaScript V8 runtime # description: | # Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine +# examples: | +# ```bash +# node -e 'console.log("Hello, World!")' +# > Hello, World! +# ``` +#
+#
+# +# +# +# +# +# +#
Run a webserver

+#   mkdir my-server
+#   pushd my-server
+#   npm init
+#   npm install --save express
+#
+# app.js: +#
+#
'use strict'
+#   var express = require('express');
+#   var app = express();
+#   
+#   app.use('/', function (req, res, next) {
+#     res.end("Hello, World!");
+#   });
+#   
+#   module.exports = app;
+#
+# server.js: +#
+#
'use strict'
+#   var http = require('http');
+#   var app = require('./app.js');
+#   http.createServer(app).listen(8080, function () {
+#     console.log('Listening on', this.address());
+#   });
+#
+#
npm start
+#
set -e set -u @@ -103,11 +145,15 @@ echo "" rm -rf "${NODEJS_UNTAR}" chown -R $(whoami) "$node_install_path/lib/node_modules/" 2>/dev/null || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/" -chown $(whoami) ""$node_install_path"/bin/" 2>/dev/null || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/" +chown $(whoami) "$node_install_path"/bin/ 2>/dev/null || $sudo_cmd chown $(whoami) "$node_install_path"/bin/ mkdir -p $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd mkdir -p $node_install_path/lib/node_modules chown -R $(whoami) $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules +# By default, npm is stupid and uses any version of node in any path. Stop that. +# npm config set scripts-prepend-node-path true +"$node_install_path"/bin/node "$node_install_path"/bin/npm --scripts-prepend-node-path=true config set scripts-prepend-node-path true + ####### # END # #######