Changes the current Node. Basically what you get if you s/ruby/node/g
with chruby, so huge props to @postmodern for their work!
- Calls
hash -r
to clear the command-lookup hash-table. - Fuzzy matching of Nodes by name.
- Defaults to the system Node.
- Optionally supports auto-switching and the
.node-version
file. - Supports [bash] and [zsh].
- Small (~100 LOC).
- Does not hook
cd
. - Does not install executable shims.
- Does not require Nodes be installed into your home directory.
- Does not automatically switch Nodes by default.
- [bash] >= 3 or [zsh]
wget -O chnode-1.0.0.tar.gz https://github.com/colinrymer/chnode/archive/v1.0.0.tar.gz
tar -xzvf chnode-1.0.0.tar.gz
cd chnode-0.3.9/
sudo make install
chnode can also be installed with [homebrew]:
brew install chnode
Or the absolute latest chnode can be installed from source:
brew install chnode --HEAD
Add the following to the ~/.bashrc
or ~/.zshrc
file:
source /usr/local/share/chnode/chnode.sh
If you wish to enable chnode system-wide, add the following to
/etc/profile.d/chnode.sh
:
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
source /usr/local/share/chnode/chnode.sh
export PATH=$HOME/.nodes/.current:$PATH
...
fi
This will prevent chnode from accidentally being loaded by /bin/sh
, which
is not always the same as /bin/bash
.
When chnode is first loaded by the shell, it will auto-detect Nodes installed
in /opt/nodes/
and ~/.nodes/
. After installing new Rubies, you must
restart the shell before chnode can recognize them.
For Nodes installed in non-standard locations, simply append their paths to
the NODES
variable:
source /usr/local/share/chnode/chnode.sh
NODES+=(
/opt/node-0.12.7
$HOME/nodes/v5.1.1
)
If you want chnode to auto-switch the current version of Node when you cd
between your different projects, simply load auto.sh
in ~/.bashrc
or
~/.zshrc
:
source /usr/local/share/chnode/chnode.sh
source /usr/local/share/chnode/auto.sh
chnode will check the current and parent directories for a [.node-version] file. Other Node switchers also understand this file: https://gist.github.com/1912050
If you wish to set a default Node, simply call chnode
in ~/.bash_profile
or
~/.zprofile
:
chnode v5.3.0
If you have enabled auto-switching, simply create a .node-version
file:
echo "v5.3.0" > ~/.node-version