LoginSignup
5

More than 5 years have passed since last update.

Raspberry PiにシステムワイドなNode.jsをndenvで入れる

Last updated at Posted at 2015-10-15

Raspberry PiにNode.jsを入れる場合aptを使って入れるのが簡単ではありますが、バージョンが少々古くなってしまうのでndenvを使って最新のv5.0を入れました。
GPIOの操作などでsudoをするのでシステムワイドに入れます。

ndenv,node-buildをrootで入れる

以下rootで作業します。

cd /usr/local
git clone https://github.com/riywo/ndenv.git
cd /usr/local/ndenv
git clone https://github.com/riywo/node-build.git plugins/node-build

echo 'export NDENV_ROOT=/usr/local/ndenv' >> /etc/bash.bashrc
echo 'export PATH=$NDENV_ROOT/bin:$PATH' >> /etc/bash.bashrc
echo 'eval "$(ndenv init -)"' >> /etc/bash.bashrc

echo 'Defaults !secure_path' >> /etc/sudoers.d/00_base
echo 'Defaults env_keep += "PATH NDENV_ROOT"' >> /etc/sudoers.d/00_base

$SHELL -lしてndenv --versioinが通ればOKです。
ユーザpiに戻ります。

Node.jsを入れる

sudo ndenv install v5.0.0
sudo ndenv global v5.0.0
sudo ndenv rehash

ユーザpiに戻ってnode -vが通ればOKです。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5