Installin NVM to install NodeJS

I am attempting to install NodeJS via a Termius terminal in Home Assistant (Raspberry Pi).

I have used the instructions at https://www.ostechnix.com/install-node-js-linux/ which suggest installing NVM first. I have attempted this several times and each time, the log output seems to suggest success but it does not seem to stick as NVM is nowhere to be found.

I have tried both methods suggested:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

One example of output is below:

`➜ ~ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 34073 0 --:–:-- --:–:-- --:–:-- 34073
=> Downloading nvm from git to ‘/root/.nvm’
=> Cloning into ‘/root/.nvm’…
remote: Enumerating objects: 286, done.
remote: Counting objects: 100% (286/286), done.
remote: Compressing objects: 100% (252/252), done.
remote: Total 286 (delta 33), reused 100 (delta 21), pack-reused 0
Receiving objects: 100% (286/286), 146.00 KiB | 808.00 KiB/s, done.
Resolving deltas: 100% (33/33), done.
=> Compressing and cleaning up git repository

0
=> Appending nvm source string to /root/.zshrc
0
=> Appending bash_completion source string to /root/.zshrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

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
➜ ~ export NVM_DIR="$HOME/.nvm"
➜ ~ `

another is below:

`➜ ~ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
=> Downloading nvm from git to ‘/root/.nvm’
=> Cloning into ‘/root/.nvm’…
remote: Enumerating objects: 286, done.
remote: Counting objects: 100% (286/286), done.
remote: Compressing objects: 100% (252/252), done.
remote: Total 286 (delta 33), reused 100 (delta 21), pack-reused 0
Receiving objects: 100% (286/286), 146.00 KiB | 830.00 KiB/s, done.
Resolving deltas: 100% (33/33), done.
=> Compressing and cleaning up git repository

0
=> Appending nvm source string to /root/.zshrc
0
=> Appending bash_completion source string to /root/.zshrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

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
➜ ~ export NVM_DIR="$HOME/.nvm"
➜ ~ `

I did also close and reopen the terminal but still n success. Any ideas?

I did also use sudo in other attempts

I have done this on a NUC using Ubuntu, so things may be a little bit different. It looks like in your case it placed the NVM files in /root/.nvm. Take a look there and see what files (if any) are there. Also as a check, from your login shell, enter: echo $HOME to see what your home directory is. Also check some of you other home directory login files like .bashrc to see if the export NVM_DIR=$HOME/.nvm, etc. lines were added to it.

I decided to try another method following instructions on https://www.instructables.com/id/Install-Nodejs-and-Npm-on-Raspberry-Pi/

It still does not seem to work. I cannot install Nodejs. I am thinking there must be some issue with permissions that I haven’t yet fathomed.

If I had to guess, I would guess /usr/local/ is not the correct place for it. I don’t use Rpi so not sure.
Here would be a couple of things to try:

  • Type $PATH and see what it prints out. You should see :/usr/local/bin: (plus others) in your PATH.
  • I think the directory structure of the file you untar’d is something like ../v12.6.1/bin/node. You should probably be copying ../v12.6.1/bin/node to /usr/local/bin/. i.e. have a directory that looks like /usr/local/bin/node/.