NodeJS: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 1: Line 1:
==Keyring==
==Keyring==
'''Node Source'''
  curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key\
  curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key\
  | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
  | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
Line 10: Line 11:
  signed-by=/usr/share/keyrings/nodesource.gpg]\
  signed-by=/usr/share/keyrings/nodesource.gpg]\
  https://deb.nodesource.com/node_19.x $(lsb_release -cs) main" >> /etc/apt/sources.list.d/nodesource.list
  https://deb.nodesource.com/node_19.x $(lsb_release -cs) main" >> /etc/apt/sources.list.d/nodesource.list
'''Yarn'''
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg\
| sudo gpg --dearmor -o /usr/share/keyrings/yarnkey.gpg
sudo echo "deb [arch=$(dpkg --print-architecture)\
signed-by=/usr/share/keyrings/yarnkey.gpg]\
https://dl.yarnpkg.com/debian stable main" > /etc/apt/sources.list.d/yarn.list


== NVM ==
== NVM ==

Revision as of 09:33, 15 December 2022

Keyring

Node Source
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key\
| sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg

sudo echo "deb [arch=$(dpkg --print-architecture)\
signed-by=/usr/share/keyrings/nodesource.gpg]\
https://deb.nodesource.com/node_19.x $(lsb_release -cs) main" > /etc/apt/sources.list.d/nodesource.list

sudo echo "deb-src [arch=$(dpkg --print-architecture)\
signed-by=/usr/share/keyrings/nodesource.gpg]\
https://deb.nodesource.com/node_19.x $(lsb_release -cs) main" >> /etc/apt/sources.list.d/nodesource.list
Yarn
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg\
| sudo gpg --dearmor -o /usr/share/keyrings/yarnkey.gpg

sudo echo "deb [arch=$(dpkg --print-architecture)\
signed-by=/usr/share/keyrings/yarnkey.gpg]\
https://dl.yarnpkg.com/debian stable main" > /etc/apt/sources.list.d/yarn.list

NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
/usr/local/lib
├── [email protected]
└── [email protected]

If you wish to uninstall them at a later point (or re-install them under your nvm Nodes), you can remove them from the system Node as follows:

nvm use system
npm uninstall -g a_module
sudo npm uninstall -g nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install 14 && node -v
nvm use system && node -v
nvm use 14

Code Server

nvm use 14
npm install -g yarn
yarn global add code-server
~/.yarn/bin/code-server
mkdir -p  ~/.local/share/code-server/logs
vim ~/.config/code-server/config.yaml

bind-addr: 127.0.0.1:8080
auth: none
password: academia
cert: false
bind-addr: 127.0.0.1:8080
auth: password
password: academia
cert: false

ln -s /home/pi/.yarn/bin/code-server /usr/local/bin/code-server
sudo vim /etc/systemd/system/code-server.service
[Unit]
Description=code-server
After=network.target

[Service]
User=pi
Group=pi

WorkingDirectory=/home/pi
Environment="PATH=/usr/bin"
ExecStart=/usr/local/bin/code-server

[Install]
WantedBy=multi-user.target
sudo systemctl disable code-server.service
sudo systemctl enable code-server.service
sudo systemctl status code-server.service
sudo systemctl start code-server.service
sudo systemctl stop code-server.service
blink » config » Hosts » New Host » SSH Config » New Host » Save
# Compression no
LocalForward 8080 127.0.0.1:8080
ExitOnForwardFailure yes

Firewall

uncomplicated firewall(ufw):
systemctl status ufw
ufw status verbose
ufw disable
ufw enable
ufw status

Knowledge

sudo npm install -g --unsafe-perm=true --allow-root
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -

References