Command 'ddev' not found on WSL2/Linux with homebrew installation - wsl-2

I followed the installation guide for ddev on WSL 2 https://ddev.readthedocs.io/en/stable/#windows-wsl2
but when I enter ddev in the ubuntu shell I only get the error:
Command 'ddev' not found, did you mean:
command 'ddv' from deb ncbi-tools-x11 (6.1.20170106+dfsg1-8)
Try: sudo apt install <deb name>
Yes I also executed the last step multiple times, to make sure that I installed everything.
Any ideas?

I assume you installed ddev using homebrew, per those instructions. When you finish installing homebrew, it gives you instructions about how to add brew to your $PATH. I imagine you didn't do that.
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/gitpod/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- Install Homebrew's dependencies if you have sudo access:
sudo apt-get install build-essential
For more information, see:
https://docs.brew.sh/Homebrew-on-Linux
- We recommend that you install GCC:
brew install gcc
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
Assuming you did a brew install drud/ddev/ddev I think if you do those steps you'll find that ddev is now in your $PATH. If you echo $PATH you should see it containing /home/linuxbrew/.linuxbrew/bin, which is where both brew and ddev will be installed.

Related

How to properly install azure-cli in Ubuntu 20.04 using homebrew?

I am trying to install the azure-cli locally from a cloned repository. I successfully installed homebrew on my end. However, when I try to install the azure-cli, the error occurs below at the very end:
From the repository, the instructions work on other devices, both on windows and linux. I don't know why it won't work on my end:
Step 1: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: brew tap-new <name>/azure-cli
Step 3: brew extract azure-cli <name>/azure-cli --version 2.29.2
Step 4: brew install <name>/azure-cli/azure-cli#2.29.2 (This is where error occurs)
*Note: the section is the name of the user of my laptop.
Other part of the installation process I've successfully installed:
Decorator setup:
sudo apt install python3-pip
sudo /usr/bin/pip3 install --system decorator
Azure Functions Core Tools:
npm i -g azure-functions-core-tools#3 --unsafe-perm true
We have ran the below cmdlets in our local environment to install Home brew & azure cli on azure Linux virtual machine which is running with Ubuntu 20.04 image.
Here are the list of Linux cmdlets used:
sudo apt update
sudo apt-get install build-essential
sudo apt install git -y ##installing git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ##Run Homebrew installation Script
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ##Add Homebrew to your path
To ensure everything is working correctly to use brew, we can run its command
brew doctor
It may give the warning to install GCC and to remove that simply install it using brew
brew install gcc
To install azure-cli with last version as per the documentation
brew install azure-cli
Here is the output screenshot for reference:
You can refer this blog to install home brew on Ubuntu20.04 linux machine.

Can I use Homebrew on Ubuntu?

I just tried to use Homebrew and Linuxbrew to install packages on my Ubuntu Server but both failed. This is how I tried to install them:
sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
I got the following warning:
Warning: /home/tong/.linuxbrew/bin is not in your PATH.
I vi my bash.bashrc in home/etc and add this:
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
Then I tried brew doctor but got No command 'brew' found. How am I able to use Homebrew on Ubuntu?
As of February 2018, installing brew on Ubuntu (mine is 17.10) machine is as simple as:
sudo apt install linuxbrew-wrapper
Then, on first brew execution (just type brew --help) you will be asked for two installation options:
me#computer:~/$ brew --help
==> Select the Linuxbrew installation directory
- Enter your password to install to /home/linuxbrew/.linuxbrew (recommended)
- Press Control-D to install to /home/me/.linuxbrew
- Press Control-C to cancel installation
[sudo] password for me:
For recommended option type your password (if your current user is in sudo group), or, if you prefer installing all the dependencies in your own home folder, hit Ctrl+D. Enjoy.
I just tried installing it using the ruby command but somehow the dependencies are not resolved hence brew does not completely install. But, try installing by cloning:
git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
and then add the following to your .bash_profile:
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
It should work..
as of august 2020 (works for kali linux as well)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
export brew=/home/linuxbrew/.linuxbrew/bin
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile // for ubuntu and debian
The following steps worked for me:
Clone it from github
git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
Open your .bash_profile file using vi ~/.bash_profile
Add these lines
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
Then type the following lines in your terminal
export PATH=$HOME/.linuxbrew/bin:$PATH
hash -r
Yes, it is done. Type brew in your terminal to check its existence.
You can just follow instructions from the Homebrew on Linux docs, but I think it is better to understand what the instructions are trying to achieve.
Understanding the installation steps can save some time
Step 1: Choose location
First of all, it is important to understand that linuxbrew will be installed on the /home directory and not inside /home/your-user (the ~ directory).
(See the reason for that at the end of answer).
Keep this in mind when you run the other steps below.
Step 2: Add linuxbrew binaries to /home :
The installation script will do it for us:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 3: Check that /linuxbrew was added to the relevant location
This can be done by simply navigating to /home.
Notice that the docs are showing it as a one-liner by adding test -d <linuxbrew location> before each command.
(Read more about the test command in here).
Step 4: Export relevant environment variables to terminal
We need to add linuxbrew to PATH and add some more environment variables to the current terminal.
We can just add the following exports to terminal (wait don't do it..):
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";
Or simply run (If your linuxbrew folder is on other location then /home - change the path):
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
(*) Because brew command is not yet identified by the current terminal (this is what we're solving right now) we'll have to specify the full path to the brew binary: /home/linuxbrew/.linuxbrew/bin/brew shellenv
Test this step by:
1 ) Run brew from current terminal to see if it identifies the command.
2 ) Run printenv and check if all environment variables were exported and that you see /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin on PATH.
Step 5: Ensure step 4 is running on each terminal
We need to add step 4 to ~/.profile (in case of Debian/Ubuntu):
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile
For CentOS/Fedora/Red Hat - replace ~/.profile with ~/.bash_profile.
Step 6: Ensure that ~/.profile or ~/.bash_profile are being executed when new terminal is opened
If you executed step 5 and failed to run brew from new terminal - add a test command like echo "Hi!" to ~/.profile or ~/.bash_profile.
If you don't see Hi! when you open a new terminal - go to the terminal preferences and ensure that the attribute of 'run command as login shell' is set.
Read more in here.
Why the installation script installs Homebrew to /home/linuxbrew/.linuxbrew - from here:
The installation script installs Homebrew to
/home/linuxbrew/.linuxbrew using sudo if possible and in your home
directory at ~/.linuxbrew otherwise. Homebrew does not use sudo
after installation. Using /home/linuxbrew/.linuxbrew allows the
use of more binary packages (bottles) than installing in your personal
home directory.
The prefix /home/linuxbrew/.linuxbrew was chosen so that users
without admin access can ask an admin to create a linuxbrew role
account and still benefit from precompiled binaries.
If you do not yourself have admin privileges, consider asking your
admin staff to create a linuxbrew role account for you with home
directory /home/linuxbrew.
Linux is now officially supported in brew - see the Homebrew 2.0.0 blog post. As shown on https://brew.sh, just copy/paste this into a command prompt:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Because all previous answers doesn't work for me for ubuntu 14.04
here what I did, if any one get the same problem:
git clone https://github.com/Linuxbrew/brew.git ~/.linuxbrew
PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$(brew --prefix)/share/man:$MANPATH"
export INFOPATH="$(brew --prefix)/share/info:$INFOPATH"
then
sudo apt-get install gawk
sudo yum install gawk
brew install hello
you can follow this link for more information.
October 2019 - Ubuntu 18.04 on WSL with oh-my-zsh;
the instructions here worked perfectly -
(first, install pre-requisites using sudo apt-get install build-essential curl file git)
finally create a ~/.zprofile with the following contents:
emulate sh -c '. ~/.profile'
Whta to do
cd /home/linuxbrew/.linuxbrew/bin
./brew doctor
You will get what path to export
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >> ~/.zshrc

Installing nodejs via nvm fails

I spend a lot of time and tons pages...
I have a an strange issue while installing nodejs on ubuntu 14.04 server (via nvm). When i run "nvm install 0.12.7" nvm gives me an answer:
curl: (6) Could not resolve host: nodejs.org
grep: /root/.nvm/bin/node-v0.12.7-linux-x86/node-v0.12.7-linux-x86.tar.gz: No such file or folder
Binary download failed, trying source.
nvm: install v0.12.7 failed!
If i type "nvm install 0.12.7" one more time, i got answer message:
Version '0.12.7' - not found - try 'nvm ls-remote' to browser available versions
I was try to install all available versions, also with -s postfix, but has a same error. I was try to install nodejs with sudo & from root. Same error. I was try uninstall and reinstall nvm with sudo and from root. Same error.
If i re-login and type nvm instal..... - I'll get a first fail, then second and so on.
I can install nodejs using apt-get, but i need to use nvm, it must be able to test project on many nodejs versus installed. Hope for help!
I also had the same issue on ubuntu 14.04. Simply append v in front of version. That is the command will be nvm install v0.12.7.
And it worked like charm for me!
Instructions to Install Nodejs latest Version for Ubuntu via NVM:
P.s - In order to Unistall NVM:
rm -rf $NVM_DIR ~/.npm ~/.bower
Start With This:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Exit the Terminal and Start Again
nvm install 14.4.0 (or your preferable version)
3....
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /etc/apt/sources.list.d/*
sudo apt-get update
4...
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
5...
sudo apt-get install -y nodejs
6..
sudo apt install build-essential
Manually adding the . ~/.nvm/nvm.sh (or bash ~/.nvm/nvm.sh) causes it to complain: N/A: version "N/A" is not yet installed. Even nvm list causes this error.
With me, it worked when I added versions directories manually 😕
mkdir ~/.nvm/versions
On that link https://github.com/nvm-sh/nvm/issues/2771 was exactly what happened to me. I just uninstalled the curl snap package and installed it again using apt and finally removed nvm and reinstalled it again, all following the instructions on their github repo https://github.com/nvm-sh/nvm#uninstalling--removal

How to install a specific version of Node on Ubuntu?

I would like to install NodeJS version 0.8.18 on Ubuntu 12.04. I tried to install the newest version and then reverting to 0.8.18 by using nvm, but when I run my code apparently there is some problem with the packages installed and the two versions (latest and 0.8.18). Since I don't know how to solve that problem, I cleaned the machine from the Node installation and thought about installing directly the version I'm interested in (v0.8.18).
The n module worked for me.
Run this code to clear npm’s cache, install n, and install the latest stable version of Node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
See: http://www.hostingadvice.com/how-to/update-node-js-latest-version/
And: https://www.npmjs.com/package/n
To install a specific version of node:
sudo n 6.11.2
To check what version:
node -v
You might need to restart
Chris Lea has 0.8.23 in his ppa repo.
This package let you add a repository to apt-get: (You can also do this manually)
sudo apt-get install software-properties-common
Add Chris Lea's repository:
sudo apt-add-repository ppa:chris-lea/node.js-legacy
Update apt-get:
sudo apt-get update
Install Node.js:
sudo apt-get install nodejs=0.8.23-1chl1~precise1
I think (feel free to edit) the version number is optional if you only add node.js-legacy. If you add both legacy and ppa/chris-lea/node.js you most likely need to add the version.
NVM (Node Version manager)
https://github.com/nvm-sh/nvm
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
Tested in Ubuntu 17.10:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
For the particular case of the most recent long term support version (recommended if you can choose):
nvm install --lts
nvm use --lts
npm --version
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, the install script hacks adds some auto sourcing to the end of your .barshrc. That works, but I prefer to remove the auto-added one and add my own:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
With this setup, you get for example:
which node
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/node
and:
which vaca
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/vaca
and if we want to use the globally installed module:
npm link vaca
node -e 'console.log(require.resolve("vaca"))'
gives:
/home/ciro/.nvm/versions/node/v0.9.0/lib/node_modules/vaca/index.js
as mentioned at:
NodeJS require a global module/package
How do I import global modules in Node? I get "Error: Cannot find module <module>"?
so we see that everything is completely contained inside the specific node version.
For projects however, you are better off just using packages installed locally under node_modules and npx for executable to be able to have independent versions across projects, global usage is mostly for the Node executable itself and global CLI utilities not specific to any project.
Setting the NPM version
Simply:
npm install npm#6.14.13 -g
The executable is placed inside the current NVM version, so everything remains nice and isolated, e.g.:
which npm
gives something like:
/home/ciro/.nvm/versions/node/v14.17.0/bin/npm
How can I change the version of npm using nvm?
It is possible to install specific version of nodejs from nodejs official distribution with using dpkg.
Check the version of you ubuntu distribution, cat /etc/lsb-release.
Check architecture of your os, uname -m.
Download preferred version of debian package from nodejs official site.
For 4.x, https://deb.nodesource.com/node_4.x/pool/main/n/nodejs/
For 5.x, https://deb.nodesource.com/node_5.x/pool/main/n/nodejs/
For 0.12.x, https://deb.nodesource.com/node_0.12/pool/main/n/nodejs/
Be careful to check nodejs-dbg or nodejs in filename.
For example, currently recent 4.x version is 4.2.4, but you can install previous 4.2.3 version.
curl -s -O https://deb.nodesource.com/node_4.x/pool/main/n/nodejs/nodejs_4.2.3-1nodesource1~trusty1_amd64.deb
sudo apt-get install rlwrap
sudo dpkg -i nodejs_4.2.3-1nodesource1~trusty1_amd64.deb
Try this way. This worked me.
wget nodejs.org/dist/v0.10.36/node-v0.10.36-linux-x64.tar.gz(download file)
Go to the directory where the Node.js binary was downloaded to, and then run command i.e, sudo tar -C /usr/local --strip-components 1 -xzf node-v0.10.36-linux-x64.tar.gz to install the Node.js binary package in “/usr/local/”.
You can check:-
$ node -v
v0.10.36
$ npm -v
1.4.28
In ubuntu specific version of node can be installed with help of nvm
install nvm
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
To install a particular version of node, use the command nvm install and add the number of the version.
nvm install 10.15.2
node -v
Say you want to install Node 10,
Firstly, download and execute the Node.js 10.x installer:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
This will add a source file for the official Node.js 10.x repo, grabs the signing key
Once the installer is done doing it’s thing, you will need to install (or upgrade) Node.js:
sudo apt install nodejs
version 0.10 is also avaible with this ppa
apt-add-repository ppa:chris-lea/node.js
install nodejs with:
apt-get install nodejs=0.10.25-1chl1~precise1
Thanks to my friend Julian Xhokaxhiu
I imagine many directed here are looking for this to add to a Dockerfile
RUN set -x \
&& curl -sL 'https://deb.nodesource.com/setup_16.x' | bash - \
&& apt-get -y install nodejs \
&& ln -s /usr/bin/nodejs /usr/local/bin/node
FYI, according to this page in the wiki of the nodejs github repo, Chris Lea's PPA (mentioned in several other answers) has been superseded by the NodeSource distributions as the main way of installing nodejs from source in Ubuntu:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
This is supported for the three latest (at the time of writing this) LTS versions of Ubuntu: 10.04 (lucid), 12.04 LTS (precise) and 14.04 (trusty).
I'm not sure this will help in installing an old version of nodejs, but I'm putting this here in case it helps others who needed to install a specific (newer) version of nodejs that isn't included in their distro's repositories.
yes, its a duplicate answer but I insist using n module to install a specific version(following commands installs node version 6.9.5).
npm install -g n
n 6.9.5
NOTE: you can use NVM software to do this in a more nodejs fashionway.
However i got issues in one machine that didn't let me use NVM. So i
have to look for an alternative ;-)
You can manually download and install.
go to nodejs > download > other releases
http://nodejs.org/dist/
choose the version you are looking for
http://nodejs.org/dist/v0.8.18/
choose distro files corresponding your environmment and download (take care of 32bits/64bits version).
Example: http://nodejs.org/dist/v0.8.18/node-v0.8.18-linux-x64.tar.gz
Extract files and follow instructions on README.md :
To build:
Prerequisites (Unix only):
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
* libexecinfo (FreeBSD and OpenBSD only)
Unix/Macintosh:
./configure
make
make install
If your python binary is in a non-standard location or has a
non-standard name, run the following instead:
export PYTHON=/path/to/python
$PYTHON ./configure
make
make install
Windows:
vcbuild.bat
To run the tests:
Unix/Macintosh:
make test
Windows:
vcbuild.bat test
To build the documentation:
make doc
To read the documentation:
man doc/node.1
Maybe you want to (must to) move the folder to a more apropiate place like /usr/lib/nodejs/node-v0.8.18/ then create a Symbolic Lynk on /usr/bin to get acces to your install from anywhere.
sudo mv /extracted/folder/node-v0.8.18 /usr/lib/nodejs/node-v0.8.18
sudo ln -s /usr/lib/nodejs/node-v0.8.18/bin/node /usr/bin/node
And if you want different release in the same machine you can use debian alternatives. Proceed in the same way posted before to download a second release. For example the latest release.
http://nodejs.org/dist/latest/ -> http://nodejs.org/dist/latest/node-v0.10.28-linux-x64.tar.gz
Move to your favorite destination, the same of the rest of release you want to install.
sudo mv /extracted/folder/node-v0.10.28 /usr/lib/nodejs/node-v0.10.28
Follow instructions of the README.md file. Then update the alternatives, for each release you have dowload install the alternative with.
sudo update-alternatives --install genname symlink altern priority [--slave genname symlink altern]
Add a group of alternatives to the system. genname is the
generic name for the master link, symlink is the name of its
symlink in the alternatives directory, and altern is the
alternative being introduced for the master link. The arguments
after --slave are the generic name, symlink name in the
alternatives directory and alternative for a slave link. Zero
or more --slave options, each followed by three arguments, may
be specified.
If the master symlink specified exists already in the
alternatives system’s records, the information supplied will be
added as a new set of alternatives for the group. Otherwise, a
new group, set to automatic mode, will be added with this
information. If the group is in automatic mode, and the newly
added alternatives’ priority is higher than any other installed
alternatives for this group, the symlinks will be updated to
point to the newly added alternatives.
for example:
sudo update-alternatives --install /usr/bin/node node /usr/lib/nodejs/node-v0.10.28 0 --slave /usr/share/man/man1/node.1.gz node.1.gz /usr/lib/nodejs/node-v0.10.28/share/man/man1/node.1
Then you can use update-alternatives --config node to choose between any number of releases instaled in your machine.
To install a specific version of nodejs in Ubuntu you can use below commands, just specify and replace the version number, for example, node_12.x will fetch the latest of 12.
curl https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb https://deb.nodesource.com/node_7.x $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install nodejs
FYI the available version for raring in Chris Lea's repo is currently 0.8.25
sudo apt-get install nodejs=0.8.25-2chl1~raring1
The Node.js project recently pushed out a new stable version with the 0.10.0 release
Use the following command on Ubuntu 13x
sudo apt-get install nodejs=0.10.18-1chl1~raring1
Install nvm using the following commands in the same order.nvm stands for node version manager.
sudo apt-get update
sudo apt-get install build-essential checkinstall libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
In case the above command does not work add -k after -o- .It should be as below:
curl -o- -k https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
Then nvm ls-remote to see the available versions.
In case you get N/A in return,run the following.
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
alternatively you can run the following commands too
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
Then nvm install #.#.# replacing # by version(say nvm 8.9.4)
finally nvm use #.#.#
Here is a list of available builds for debian: https://github.com/nodesource/distributions/tree/master/deb
For this example, lets assume you want version 14 (LTS at the time of writing)
We can download this script from github, execute it and install the version of node we want. For security reasons it's a good idea to read the script prior to executing it.
curl -sL https://raw.githubusercontent.com/nodesource/distributions/master/deb/setup_14.x | bash
apt-get install -y nodejs # may or may not require sudo based on your setup
I like this approach because it doesn't require extraneous dependencies like nvm to target specific versions
If you are building for a different distro or architecture you can find more builds here https://nodejs.org/dist/

Homebrew install issues

I am having some trouble with brew installs. So I have done the following:
Uninstalled homebrew with:
$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
Reinstalled homebrew with:
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go/install)"
$ brew update
Already up-to-date.
$ brew doctor
Your system is raring to brew.
Try running any install & I get the following output:
$ brew install node
Error: Permission denied - /Library/Caches/Homebrew/Formula/node.brewing
What is going on here? This is also giving me issues with using npm and yeoman which I'd really like to use :(
Did you perhaps install brew with an other user, or with sudo previously?
Check the permissions of /Library/Caches/Homebrew, and force it to be writable for your user, by either changing its owner, or its permissions.
You might also try to uninstall with something like https://gist.github.com/1173223 and try the install again.
This thing told me to tell you to update that install command to
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Resources