Node.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Node.js == | |||
== Install == | |||
apt install nodejs | |||
npm install -g npm | |||
npm install -g npm | |||
=== Install version 18 === | |||
Install 18: | |||
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh | |||
sudo bash nodesource_setup.sh | |||
sudo apt install nodejs | |||
Install 20: <ref>https://joshtronic.com/2023/04/23/how-to-install-nodejs-20-on-ubuntu-2004-lts/</ref> | |||
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - | |||
sudo apt install nodejs | |||
/etc/apt/sources.list.d/nodesource.list | |||
deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main | |||
== Node Version Manager - nvm == | |||
== Node.js | NOTE: nvm does local user install only - not global | ||
Recommend using Node Version Manager <ref>https://stackoverflow.com/questions/76318653/how-can-i-install-node-js-version-18-on-ubuntu-22-04</ref> | |||
https://github.com/nvm-sh/nvm | |||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash | |||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | |||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | |||
export NVM_DIR="$HOME/.nvm" | |||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |||
nvm install 18 | |||
nvm use 18 | |||
nvm install 20 | |||
nvm use 20 | |||
Uninstall: | |||
rm -rf .nvm | |||
# remove the lines added to .bashrc | |||
== Version == | |||
npm -V # lots of details upper case V | |||
... usage help plus ... | |||
npm@10.7.0 /root/.nvm/versions/node/v20.15.0/lib/node_modules/npm | |||
npm -v # upper case V | |||
10.7.0 | |||
node -v # lower case v | |||
v20.15.0 | |||
== w3schools == | |||
== keywords == | |||
[[Category:Node.js]] | |||
[[Category:Node]] |
Latest revision as of 21:29, 20 September 2024
Node.js
Install
apt install nodejs
npm install -g npm
npm install -g npm
Install version 18
Install 18:
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt install nodejs
Install 20: [1]
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install nodejs
/etc/apt/sources.list.d/nodesource.list deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main
Node Version Manager - nvm
NOTE: nvm does local user install only - not global
Recommend using Node Version Manager [2]
https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 18 nvm use 18
nvm install 20 nvm use 20
Uninstall:
rm -rf .nvm # remove the lines added to .bashrc
Version
npm -V # lots of details upper case V ... usage help plus ... npm@10.7.0 /root/.nvm/versions/node/v20.15.0/lib/node_modules/npm
npm -v # upper case V 10.7.0
node -v # lower case v v20.15.0