NodeJS

Revision as of 17:30, 17 August 2019 by David (talk | contribs) (Created page with "Node.js is a JavaScript environment based on Chrome's V8 JavaScript engine. Node Package Manager (npm) is used to manager node packages installed on your computer or used in y...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Node.js is a JavaScript environment based on Chrome's V8 JavaScript engine. Node Package Manager (npm) is used to manager node packages installed on your computer or used in your node projects. An alternative to npm is yarn.

Installation

Windows

Just download the latest LTS release from the Node.js website

Linux

Using the Node Version Manager (nvm) is recommended. This does not require sudo as nvm is installed in your home directory.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
# Reload .bashrc
source ~/.bashrc
nvm install --lts node
nvm install-latest-npm

Usage

JavaScript files can be run directly using node index.js

NPM

To add node packages to an new project. Use npm init
To download the dependencies for a node project, run npm install or npm ci. npm install installs the latest dependencies listed in package.json subject to the requirements listed in that file. It also updates package-lock.json.
npm ci installs exact versions from the package-lock.json.