setup/doc/node.md

82 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2022-05-03 21:48:36 +02:00
# Setup Node
2022-03-15 09:39:08 +01:00
* update apt repository cache
```
sudo apt update
```
## Using APT
* install node.js and npm
```
sudo apt-get install nodejs npm --no-install-recommends
```
2023-09-13 07:37:25 +02:00
## Using NVM
* configure Node.js: [Here](https://github.com/nvm-sh/nvm) we find a bash script to manage multiple active node.js versions
```
node -v
which node
chmod 700 ~/.profile
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
command -v nvm
nvm -v
. ~/.profile
nvm -v
command -v nvm
echo $NVM_DIR
```
2023-09-13 07:37:25 +02:00
* OPTION: log out and log in again so that the configuration is updated
2022-03-15 09:39:08 +01:00
2023-09-13 07:37:25 +02:00
* Select and Install a Node.js version
2022-03-15 09:39:08 +01:00
```
2023-09-13 07:37:25 +02:00
nvm version-remote --lts
nvm ls-remote| grep 'Latest LTS'| grep v18
2023-09-13 07:37:25 +02:00
nvm i <lts>
2022-03-15 09:39:08 +01:00
```
2023-09-13 07:37:25 +02:00
* NOTE: Make sure node.js is available in the correct version
2022-03-15 09:39:08 +01:00
```
2023-09-13 07:37:25 +02:00
which node
2022-03-15 09:39:08 +01:00
```
2023-09-13 07:37:25 +02:00
* OPTION: Compare nvm's and user's Node.js version
2022-03-15 09:39:08 +01:00
```
2023-09-13 07:37:25 +02:00
/usr/bin/node -v
node -v
2022-03-15 09:39:08 +01:00
```
### Helpful NVM instructions
* install specific node version
```
nvm install 12.20.1
```
* list installed node versions for the current user
```
nvm ls
```
* find available node versions for installation
```
nvm ls-remote
```
* select a different node version for the current session only
```
nvm use 12.20.1
```
* find the default version for the current user
```
nvm run default --version
```
* run node script with the desired node version
```
2022-05-03 21:48:36 +02:00
nvm exec 12.20.1 <node script>.js
2022-03-15 09:39:08 +01:00
```