sudo pacman -Sy nodejs sudo pacman -Sy npm
choco install -y nodejs choco install -y nodejs-lts choco install -y nodejs.install
npm
is typically required, too: sudo apt install nodejs sudo apt install npm
$ node -v v12.22.12
var http = require('http'); http.createServer( function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); } ).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
$ node hello-world.js
node
without a script name: PS C:\Users\Rene> node
> process.exit()
logging
module. logging
module needs not be added with require('logging')
(2020-09-23: this seems not to be the case anymore). console.log('some text'); console.log('more text'); console.log('the end.' );
fs
, http
, …)
npm install …
.
./
, ../
in their name and having on of the suffixes .js
, .json
, .mjs
, .cjs
, .wasm
or .node
). require
(which is not part of the standard JavaScript API). require
, the module must either be package.json
file, or
process.env.ENVVAR
: console.log('Home directory: ' + process.env.HOME);
/tmp
on Linux) is returned by os.tmpdir()
or os.tmpdir
: const os = require('os'); console.log('The temporary directory is: ' + os.tmpdir);
npm install yarn -g
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
~/.nvm/versions/node/v19.…/bin/node
: nvm install 19