LoginSignup
11
12

More than 5 years have passed since last update.

node.jsをraspberry piにインストールしてみる

Posted at

ubuntuにインストールした時と同じように行ってみる。

まずはnvmのインストール

$ git clone https://github.com/creationix/nvm.git ~/.nvm
Cloning into '/home/pi/.nvm'...
remote: Counting objects: 4142, done.
remote: Total 4142 (delta 0), reused 0 (delta 0), pack-reused 4142
Receiving objects: 100% (4142/4142), 1.02 MiB | 497.00 KiB/s, done.
Resolving deltas: 100% (2406/2406), done.
Checking connectivity... done.

入ったようだ。

$ nvm --version
0.29.0

node.jsのインストール

引き続きnode.jsのv5.1.0をインストールする。

$ nvm install v5.1.0
Downloading https://nodejs.org/dist/v5.1.0/node-v5.1.0-linux-armv6l.tar.xz...
######################################################################## 100.0%
WARNING: checksums are currently disabled for node.js v4.0 and later

Now using node v5.1.0 (npm v3.3.12)

ログインの都度、nvmとnode.jsの5.1を有効にするように.bash.rcの末尾に以下を追加

if [[ -f ~/.nvm/nvm.sh ]]; then
source ~/.nvm/nvm.sh
nvm use 5.1     
fi

改めてログインしてみる。

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Nov 30 22:22:33 2015 from ***********
Now using node v5.1.0 (npm v3.3.12)

PC上のubuntuでは気にならなかったけど、ログインプロンプトが出てくるまでにすごく時間がかかる。

$node -v
v5.1.0

ちゃんとv5.1が動作している。

npmのインストール

apt-getからインストールする。

$sudo apt-get install  npm

いろいろなものが派生してインストールされる。raspberry pi上ではすごく時間がかかる(手元の環境で10分ほどか)。

$ npm --version
3.3.12

念のため、npm自身もupdateする(-gはグローバルオプション)。

$ sudo npm update -g npm
#なにも起こらなかった

ちなみに上記コマンド、sudoで行わないと、全体のupdateをかけるようだ(2015/11/30時点では詳細未解明)。

$ npm update -g npm
loadRequestedDeps → gunzT ▄ ╢████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟

expressのインストール

npm install express --save
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
/home/pi
└─┬ express@4.13.3 
  ├─┬ accepts@1.2.13 
  │ ├─┬ mime-types@2.1.7 
  │ │ └── mime-db@1.19.0 
  │ └── negotiator@0.5.3 
  ├── array-flatten@1.1.1 
  ├── content-disposition@0.5.0 
  ├── content-type@1.0.1 
  ├── cookie@0.1.3 
  ├── cookie-signature@1.0.6 
  ├─┬ debug@2.2.0 
  │ └── ms@0.7.1 
  ├── depd@1.0.1 
  ├── escape-html@1.0.2 
  ├── etag@1.7.0 
  ├─┬ finalhandler@0.4.0 
  │ └── unpipe@1.0.0 
  ├── fresh@0.3.0 
  ├── merge-descriptors@1.0.0 
  ├── methods@1.1.1 
  ├─┬ on-finished@2.3.0 
  │ └── ee-first@1.1.1 
  ├── parseurl@1.3.0 
  ├── path-to-regexp@0.1.7 
  ├─┬ proxy-addr@1.0.8 
  │ ├── forwarded@0.1.0 
  │ └── ipaddr.js@1.0.1 
  ├── qs@4.0.0 
  ├── range-parser@1.0.3 
  ├─┬ send@0.13.0 
  │ ├── destroy@1.0.3 
  │ ├─┬ http-errors@1.3.1 
  │ │ └── inherits@2.0.1 
  │ ├── mime@1.3.4 
  │ └── statuses@1.2.1 
  ├── serve-static@1.10.0 
  ├─┬ type-is@1.6.9 
  │ └── media-typer@0.3.0 
  ├── utils-merge@1.0.0 
  └── vary@1.0.1 

npm WARN ENOENT ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN EPACKAGEJSON pi No description
npm WARN EPACKAGEJSON pi No repository field.
npm WARN EPACKAGEJSON pi No README data
npm WARN EPACKAGEJSON pi No license field.
pi@raspberrypi ~ $ 
11
12
0

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
11
12