Skip to content

Instantly share code, notes, and snippets.

@igoralves1
Last active July 9, 2024 18:08
Show Gist options
  • Save igoralves1/3ae1b17f669312e0fa9000a0ff54b863 to your computer and use it in GitHub Desktop.
Save igoralves1/3ae1b17f669312e0fa9000a0ff54b863 to your computer and use it in GitHub Desktop.
nvm

(NVM) - Ubuntu: Installing Node Using the Node Version Manager (Node+npm)

Check the Java jdk and JRE versions. If y dont have it. Install them: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04

ila@ila:/etc/apt$ java -version
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-122.04.1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Ubuntu-122.04.1, mixed mode, sharing)

Run the flow

sudo apt update
sudo apt upgrade -y 
sudo apt install unzip -y
sudo apt install openjdk-14-jre-headless -y 
# Get the most recent nvm version -> https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source ~/.bashrc
nvm list-remote

Based on NODE org downloads docs, choose the Latest LTS Version. Today it is the 14.16.0 (includes npm 6.14.11)

$ nvm list-remote

v14.15.4   (LTS: Fermium)
v14.15.5   (LTS: Fermium)
v14.16.0   (Latest LTS: Fermium)
v15.0.0

At that point there is no NODE installed

$ nvm list

N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.1 (-> N/A)
lts/fermium -> v14.16.1 (-> N/A)

Install the version - 14.16.1

$ nvm install v14.16.1

Check again IF node v14.16.1 is installed

$ nvm list

v14.16.1
default -> v14.16.1
node -> stable (-> v14.16.1) (default)
stable -> 14.16 (-> v14.16.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> v14.16.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.1 (-> N/A)
lts/fermium -> v14.16.1

MAC: Installing Node Using the Node Version Manager (Node+npm)

First instal NVM latest version

cd /Users/ialves/
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

source .bashrc

Check if NVM was installed:

$ nvm --version

0.37.2

Check available NODE versions on LOCAL:

$ nvm list

N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)

Check available NODE versions on REMOTE:

$ nvm list-remote

v14.15.4   (LTS: Fermium)
v14.15.5   (LTS: Fermium)
v14.16.0   (Latest LTS: Fermium)
v15.0.0

Install Locally latest version available v14.16.0 (Latest LTS: Fermium)

$ nvm install v14.16.0

Check if the NODE version v14.16.0 (Latest LTS: Fermium) was installed on LOCAL:

$ nvm list

v14.16.0
default -> v14.16.0
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.16.0) (default)
stable -> 14.16 (-> v14.16.0) (default)
lts/* -> lts/fermium (-> v14.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.0 (-> N/A)
lts/erbium -> v12.21.0 (-> N/A)
lts/fermium -> v14.16.0

Check again IF node v14.16.1 is installed

$ nvm --v

Node Version Manager (v0.37.2)

Note: <version> refers to any version-like string nvm understands. This includes:
  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
  - default (built-in) aliases: node, stable, unstable, iojs, system
  - custom aliases you define with `nvm alias foo`
  
  - (Check latest NVM version at - https://github.com/nvm-sh/nvm#install--update-script)

 Any options that produce colorized output should respect the `--no-colors` option.

Usage:
  nvm --help                                  Show this message
    --no-colors                               Suppress colored output
  nvm --version                               Print out the installed version of nvm
  nvm install [<version>]                     Download and install a <version>. Uses .nvmrc if available and version is omitted.
   The following optional arguments, if provided, must appear directly after `nvm install`:
    -s                                        Skip binary download, install from source only.
    --reinstall-packages-from=<version>       When installing, reinstall packages installed in <node|iojs|node version number>
    --lts                                     When installing, only select from LTS (long-term support) versions
    --lts=<LTS name>                          When installing, only select from versions for a specific LTS line
    --skip-default-packages                   When installing, skip the default-packages file if it exists
    --latest-npm                              After installing, attempt to upgrade to the latest working npm on the given node version
    --no-progress                             Disable the progress bar on any downloads
    --alias=<name>                            After installing, set the alias specified to the version specified. (same as: nvm alias <name> <version>)
    --default                                 After installing, set default alias to the version specified. (same as: nvm alias default <version>)
  nvm uninstall <version>                     Uninstall a version
  nvm uninstall --lts                         Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
  nvm uninstall --lts=<LTS name>              Uninstall using automatic alias for provided LTS line, if available.
  nvm use [<version>]                         Modify PATH to use <version>. Uses .nvmrc if available and version is omitted.
   The following optional arguments, if provided, must appear directly after `nvm use`:
    --silent                                  Silences stdout/stderr output
    --lts                                     Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=<LTS name>                          Uses automatic alias for provided LTS line, if available.
  nvm exec [<version>] [<command>]            Run <command> on <version>. Uses .nvmrc if available and version is omitted.
   The following optional arguments, if provided, must appear directly after `nvm exec`:
    --silent                                  Silences stdout/stderr output
    --lts                                     Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=<LTS name>                          Uses automatic alias for provided LTS line, if available.
  nvm run [<version>] [<args>]                Run `node` on <version> with <args> as arguments. Uses .nvmrc if available and version is omitted.
   The following optional arguments, if provided, must appear directly after `nvm run`:
    --silent                                  Silences stdout/stderr output
    --lts                                     Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=<LTS name>                          Uses automatic alias for provided LTS line, if available.
  nvm current                                 Display currently activated version of Node
  nvm ls [<version>]                          List installed versions, matching a given <version> if provided
    --no-colors                               Suppress colored output
    --no-alias                                Suppress `nvm alias` output
  nvm ls-remote [<version>]                   List remote versions available for install, matching a given <version> if provided
    --lts                                     When listing, only show LTS (long-term support) versions
    --lts=<LTS name>                          When listing, only show versions for a specific LTS line
    --no-colors                               Suppress colored output
  nvm version <version>                       Resolve the given description to a single local version
  nvm version-remote <version>                Resolve the given description to a single remote version
    --lts                                     When listing, only select from LTS (long-term support) versions
    --lts=<LTS name>                          When listing, only select from versions for a specific LTS line
  nvm deactivate                              Undo effects of `nvm` on current shell
    --silent                                  Silences stdout/stderr output
  nvm alias [<pattern>]                       Show all aliases beginning with <pattern>
    --no-colors                               Suppress colored output
  nvm alias <name> <version>                  Set an alias named <name> pointing to <version>
  nvm unalias <name>                          Deletes the alias named <name>
  nvm install-latest-npm                      Attempt to upgrade to the latest working `npm` on the current node version
  nvm reinstall-packages <version>            Reinstall global `npm` packages contained in <version> to current version
  nvm unload                                  Unload `nvm` from shell
  nvm which [current | <version>]             Display path to installed node version. Uses .nvmrc if available and version is omitted.
    --silent                                  Silences stdout/stderr output when a version is omitted
  nvm cache dir                               Display path to the cache directory for nvm
  nvm cache clear                             Empty cache directory for nvm
  nvm set-colors [<color codes>]              Set five text colors using format "yMeBg". Available when supported.
                                               Initial colors are:
                                                   g  b  y  r  e
                                               Color codes:
                                                 r/R = red / bold red
                                                 g/G = green / bold green
                                                 b/B = blue / bold blue
                                                 c/C = cyan / bold cyan
                                                 m/M = magenta / bold magenta
                                                 y/Y = yellow / bold yellow
                                                 k/K = black / bold black
                                                 e/W = light grey / white

Example:
  nvm install 8.0.0                     Install a specific version number
  nvm use 8.0                           Use the latest available 8.0.x release
  nvm run 6.10.3 app.js                 Run app.js using node 6.10.3
  nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing to node 4.8.3
  nvm alias default 8.1.0               Set default node version on a shell
  nvm alias default node                Always default to the latest available node version on a shell

  nvm install node                      Install the latest available version
  nvm use node                          Use the latest version
  nvm install --lts                     Install the latest LTS version
  nvm use --lts                         Use the latest LTS version

  nvm set-colors cgYmW                  Set text colors to cyan, green, bold yellow, magenta, and white

Note:
  to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)

Sources

========================

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install $ aws --version aws-cli/2.1.28 Python/3.8.8 Linux/5.4.0-1037-aws exe/x86_64.ubuntu.20 prompt/off

Create a new Access keys if you dont have one. In IAM > USERS > Create Access (https://console.aws.amazon.com/iam/home?region=us-east-2#/users/ialves@scican.com?section=security_credentials) Grab the AWS Access Key ID [None] and the AWS Secret Access Key [None] from the csv from the new Access keys process. Use them below

Configuration basics (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) $ aws configure AWS Access Key ID [None]: xxx AWS Secret Access Key [None]: xxx Default region name [None]: us-east-1 Default output format [None]: json

Test if the connection with AWS is working: $ aws s3 ls should be able to see the S3 buckets list. Connetion is working ! ###############################################################################

SSH keys for AWS CodeCommit

$ cd .ssh/ $ ll total 12 drwx------ 2 ubuntu ubuntu 4096 Mar 1 21:56 ./ drwxr-xr-x 9 ubuntu ubuntu 4096 Mar 1 22:29 ../ -rw------- 1 ubuntu ubuntu 398 Mar 1 21:56 authorized_keys $ ssh-keygen Enter file in which to save the key (/home/user-name/.ssh/id_rsa): devig1UbuntuHome (Use same instance name to keep consistency) Enter passphrase:devig1UbuntuHome Enter same passphrase again:devig1UbuntuHome

$ ll total 20 drwx------ 2 ubuntu ubuntu 4096 Mar 1 22:37 ./ drwxr-xr-x 9 ubuntu ubuntu 4096 Mar 1 22:29 ../ -rw------- 1 ubuntu ubuntu 398 Mar 1 21:56 authorized_keys -rw------- 1 ubuntu ubuntu 2655 Mar 1 22:37 devig1UbuntuHome -rw-r--r-- 1 ubuntu ubuntu 576 Mar 1 22:37 devig1UbuntuHome.pub

$ cat ~/.ssh/devig1UbuntuHome.pub copy the output

Go to IAM > Upload SSH public key () paste the (cat ~/.ssh/devig1UbuntuHome.pub) content create a config file in the ~/.ssh directory $ touch config $ ll total 20 drwx------ 2 ubuntu ubuntu 4096 Mar 1 22:44 ./ drwxr-xr-x 9 ubuntu ubuntu 4096 Mar 1 22:29 ../ -rw------- 1 ubuntu ubuntu 398 Mar 1 21:56 authorized_keys -rw-rw-r-- 1 ubuntu ubuntu 0 Mar 1 22:44 config -rw------- 1 ubuntu ubuntu 2655 Mar 1 22:37 devig1UbuntuHome -rw-r--r-- 1 ubuntu ubuntu 576 Mar 1 22:37 devig1UbuntuHome.pub

$ sudo vi config paste the follow: Host git-codecommit.*.amazonaws.com User APKAVKRIAOFCGVHFX55R IdentityFile ~/.ssh/devig1UbuntuHome

Host git-codecommit.*.amazonaws.com User APKAVKRIAOFCCQDQAOVT IdentityFile ~/.ssh/codecommit

Host github.com AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/githubialvescican

$ sudo chmod 600 config
$ ll total 24 drwx------ 2 ubuntu ubuntu 4096 Mar 1 22:47 ./ drwxr-xr-x 9 ubuntu ubuntu 4096 Mar 1 22:29 ../ -rw------- 1 ubuntu ubuntu 398 Mar 1 21:56 authorized_keys -rw------- 1 ubuntu ubuntu 103 Mar 1 22:47 config -rw------- 1 ubuntu ubuntu 2655 Mar 1 22:37 devig1UbuntuHome -rw-r--r-- 1 ubuntu ubuntu 576 Mar 1 22:37 devig1UbuntuHome.pub

Teste connection: $ ssh git-codecommit.us-east-1.amazonaws.com The authenticity of host 'git-codecommit.us-east-1.amazonaws.com (52.94.233.146)' can't be established. RSA key fingerprint is SHA256:eLMY1j0DKA4uvDZcl/KgtIayZANwX6t8+8isPtotBoY. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'git-codecommit.us-east-1.amazonaws.com,52.94.233.146' (RSA) to the list of known hosts. Enter passphrase for key '/home/ubuntu/.ssh/devig1UbuntuHome': devig1UbuntuHome You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host. Connection to git-codecommit.us-east-1.amazonaws.com closed.

Finished !

###############################################################################

Create vhosts folder and clone inside it.

$ sudo mkdir ~/vhosts

Notes:

https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent Open your ~/.ssh/config file, then modify the file, replacing ~/.ssh/id_ed25519 if you are not using the default location and name for your id_ed25519 key.

Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519 Note: If you chose not to add a passphrase to your key, you should omit the UseKeychain line.

https://gist.github.com/rbialek/1012262 Host github.com User git Hostname github.com PreferredAuthentications publickey IdentityFile /home/user/.ssh/id_rsa

https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment