Ubuntu12.04にNode.jsをインストールする

Beaglebone BlackのSDカードにインストールしたUbuntu12.04にNode.jsをインストールする。

Ubuntuパッケージのnode.jsは古かった

Ubuntuに、node.jsのパッケージは一応あるようだ。

ubuntu@ubuntu-armhf:~$ apt-cache search nodejs
node-lru-cache - Javascript least-recently-used cache object - NodeJS
node-request - simplified HTTP request client for NodeJS
node-semver - Semantic versioner for NodeJS
nodejs - Node.js event-based server-side javascript engine
nodejs-dbg - Node.js event-based server-side javascript engine (debug)
nodejs-dev - Development files for Node.js

バージョンを調べる。0.6.12~dfsg1-1ubuntu1とは、いかにも古い。

ubuntu@ubuntu-armhf:~$ apt-get install -s nodejs
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libc-ares2 libev4 libicu48 libv8-3.7.12.22
The following NEW packages will be installed:
  libc-ares2 libev4 libicu48 libv8-3.7.12.22 nodejs
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Inst libc-ares2 (1.7.5-1 Ubuntu:12.04/precise [armhf])
Inst libicu48 (4.8.1.1-3ubuntu0.1 Ubuntu:12.04/precise-updates [armhf])
Inst libv8-3.7.12.22 (3.7.12.22-3 Ubuntu:12.04/precise [armhf])
Inst libev4 (1:4.11-1 Ubuntu:12.04/precise [armhf])
Inst nodejs (0.6.12~dfsg1-1ubuntu1 Ubuntu:12.04/precise [armhf])
Conf libc-ares2 (1.7.5-1 Ubuntu:12.04/precise [armhf])
Conf libicu48 (4.8.1.1-3ubuntu0.1 Ubuntu:12.04/precise-updates [armhf])
Conf libv8-3.7.12.22 (3.7.12.22-3 Ubuntu:12.04/precise [armhf])
Conf libev4 (1:4.11-1 Ubuntu:12.04/precise [armhf])
Conf nodejs (0.6.12~dfsg1-1ubuntu1 Ubuntu:12.04/precise [armhf])

armhf.orgで配布しているバイナリをインストールする

nodejs.orgの最新版は、v0.10.26だった。
http://nodejs.org/


セルフのスクラッチビルドは、トモさんが既に試している。
http://tomowatanabe.hatenablog.com/entry/2013/12/17/102452
これは時間がかかりそう。


若干古いが、ビルド済みのバイナリをarmhf.orgで配布しているので、それを使うことにする。
これ。

Node Ubuntu Precise
node-v0.10.21-precise-armhf.tar.xz (November 7, 2013)
md5: d326c94e46b8c5f91c803e1e66f1a5e8
installation: tar xJvf node-v*-precise-armhf.tar.xz -C /usr/local --strip-components 1

ダウンロードする。

ubuntu@ubuntu-armhf:~$ wget http://s3.armhf.com/debian/precise/node-v0.10.21-precise-armhf.tar.xz

インストールする。

ubuntu@ubuntu-armhf:~$ tar xJvf node-v*-precise-armhf.tar.xz -C /usr/local --strip-components 1

なんか、"Operation not permitted"が死ぬほど...
rootで入れる。

ubuntu@ubuntu-armhf:~$ sudo tar xJvf node-v*-precise-armhf.tar.xz -C /usr/local --strip-components 1

入った。


起動テスト。

ubuntu@ubuntu-armhf:~$ node
>

お、終わり方がわかんない...
process.exit();か。


npmも入っている。

ubuntu@ubuntu-armhf:~$ npm --help

Usage: npm <command>

where <command> is one of:
    add-user, adduser, apihelp, author, bin, bugs, c, cache,
    completion, config, ddp, dedupe, deprecate, docs, edit,
    explore, faq, find, find-dupes, get, help, help-search,
    home, i, info, init, install, isntall, issues, la, link,
    list, ll, ln, login, ls, outdated, owner, pack, prefix,
    prune, publish, r, rb, rebuild, remove, repo, restart, rm,
    root, run-script, s, se, search, set, show, shrinkwrap,
    star, stars, start, stop, submodule, tag, test, tst, un,
    uninstall, unlink, unpublish, unstar, up, update, v,
    version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm faq          commonly asked questions
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /home/ubuntu/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@1.3.11 /usr/local/lib/node_modules/npm