Linux in VM - curl failing to download nvm file? - linux

Trying to install nvm following the command from the website (curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash) and I get this error
=> Downloading nvm as script to '/home/ahmed/.nvm'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/bash_completion'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm.sh'
=> nvm source string already in /home/ahmed/.bashrc
=> bash_completion source string already in /home/ahmed/.bashrc
main: line 433: /home/ahmed/.nvm/nvm.sh: No such file or directory
=> 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

It' related to a bug with snap version of curl. Try remove it and install curl with apt instead.
sudo snap remove curl
sudo apt install curl
Reference:
https://github.com/nvm-sh/nvm/issues/2504#issuecomment-839570439

It seems nvm is already installed, try to run it.

Ended up reinstalling the OS which fixed the problem

Related

Installing NVM on Ubuntu 20.04 LTS?

Trying to install NVM on Ubuntu 20.04 LTS. When I run the install script this happens:
ole#ole-ThinkPad-T470:~/Temp/nv$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
=> Downloading nvm as script to '/home/ole/.nvm'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm.sh'
=> nvm source string already in /home/ole/.bashrc
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/bash_completion'
=> bash_completion source string already in /home/ole/.bashrc
main: line 433: /home/ole/.nvm/nvm.sh: No such file or directory
=> 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
But if I wget one of the scripts that fails to download it works:
ole#ole-ThinkPad-T470:~/Temp/nv$ wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec
--2021-05-25 18:39:08-- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 344 [text/plain]
Saving to: ‘nvm-exec.1’
nvm-exec.1 100%[========================================================>] 344 --.-KB/s in 0s
2021-05-25 18:39:08 (4.25 MB/s) - ‘nvm-exec.1’ saved [344/344]
ole#ole-ThinkPad-T470:~/Temp/nv$ ls
nvm-exec
Thoughts?
It looks like it's related to installing wget or curl with snap on Ubuntu:
https://github.com/nvm-sh/nvm/issues/2504
Here's what fixed it for me:
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node
uninstalling snap curl and installing apt install resolved this for me as well,
sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node

Trying to install nvm

I'm trying to install nvm but keep getting errors.
I run the install script
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
and I get
=> nvm is already installed in /Users/xxxxx/.nvm, trying to update using git
=> => Compressing and cleaning up git repository
=> nvm source string already in /Users/xxxxx/.bash_profile
=> bash_completion source string already in /Users/xxxxx/.bash_profile
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
/Users/xxxxx/.nvm/versions/node/v10.17.0/lib
└── yarn#1.22.4
=> 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
=> 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
If I close and open a new terminal window and check for nvm with nvm -v
I get
zsh: command not found: nvm
Mac OS Fix
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
After this close terminal and open it again.
Voila it should work like charm

NVM Install Error: Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.

I JUST wiped and reformatted my entire Macbook Retina drive to start from scratch,
installed homebrew,
installed xcode and accepted terms and conditions,
went to install nvm with curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash and got the following error:
=> nvm is already installed in /Users/dillon/.nvm, trying to update using git
=> => Compressing and cleaning up git repository
=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
OR
=> Append the following lines to the correct file yourself:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
=> 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
echo $PATH returns /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin if that's any help.
I tried opening an issue on github but haven't received a response
Any idea what I can do to get nvm and node properly running?
Didn't read this from the nvm install instructions. It fixed my problem.
Note: On OS X, if you get nvm: command not found after running the
install script, one of the following might be the reason:-
your system may not have a [.bash_profile file] where the command is set up. Simply create one with touch ~/.bash_profile and run the
install script again
you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
The following command solved my problem:
sudo chown -R $USER:$(id -gn $USER) /Users/david/.config
Note: Change 'david' in the path for your user.

Can't use nvm from bash script

I am trying to write a shell script to automate my dev environment set-up (install python, nvm, node, mongo etc...). I am using nvm to install Node. It tells you to close and reopen your terminal to start using the nmv command. I tried to source .bashrc and .profile to make the command available right away so I can continue running the script with nvm install, but it doesn't work.
Here is the segment of my script related to installing NVM / Node:
#install nvm and latest node version
# sourcing profile and bashrc is not working here. nvm does not execute the next two lines to install node.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
source ~/.profile
source ~/.bashrc
nvm install 5.0
nvm alias default node
I get these messages, but please note that I've already run the script and NVM / Node are already installed and working. I can also use nvm and node in the same terminal I run the script from after it completes. It just doesn't work in the script.
=> Downloading nvm from git to '/home/myDir/.nvm'
=> fatal: destination path '/home/myDir/.nvm' already exists and is not an empty directory.
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
=> Source string already in /home/myDir/.bashrc
=> Close and reopen your terminal to start using nvm
./install-programs.sh: line 27: nvm: command not found
./install-programs.sh: line 28: nvm: command not found
if you have nvm running on the main shell, you just need to add:
export NVM_DIR=$HOME/.nvm;
source $NVM_DIR/nvm.sh;
in your script
Here is what worked for me.
First install nvm (once and separately) using SSH or console:
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
Then in your script, loading your profile as follows:
. ~/.nvm/nvm.sh
. ~/.profile
. ~/.bashrc
And with some luck nvm should become available inside the script.
nvm install 4.4.2
Tada!
Just put this on top of your script:
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
Worked like a charm here.
This script works fine for me:
#!/usr/bin/env bash
if [ ! -d ~/.nvm ]; then
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
source ~/.nvm/nvm.sh
source ~/.profile
source ~/.bashrc
nvm install 5.0
npm install
npm run front
fi
Nowadays, you can simply do this:
env NODE_VERSION=<dd> /home/<user>/.nvm/nvm-exec npm run front
Simply sourcing nvm.sh didn't work for me (from a systemd .service file), the PATH didn't include ~/.nvm...
Credit where credit is due: https://gist.github.com/joepie91/73ce30dd258296bd24af23e9c5f761aa#gistcomment-2215867

NVM: command not found but present in .bashrc

I'm trying to install nvm on my Mac OS (according to https://github.com/creationix/nvm#installation)
I'm running
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.27.1/install.sh | bash
I see that my .bashrc contains
export NVM_DIR="/Users/yanamikhaylenko/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
However when I run
nvm install node && nvm alias default node
I receive
-bash: nvm: command not found
Should I export path in .profile or do something else?
Please, note that I'm using Node.js v 4.1.1

Resources