こちらの記事を参考に行いました.
$ sudo apt-get update
$ sudo apt-get install git-core curl build-essential openssl libssl-dev
$ git clone https://github.com/joyent/node.git && cd node
$ ./configure
$ make
$ sudo make install
$ node -v
$ cd
$ curl http://npmjs.org/install.sh | sudo sh
記事の通り上記を実行すると
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3927 100 3927 0 0 4348 0 --:--:-- --:--:-- --:--:-- 10121
fetching: http://registry.npmjs.org/npm/-/npm-1.0.22.tgz
node.js:63
throw e;
^
Error: Cannot find module 'graceful-fs'
at loadModule (node.js:275:15)
at require (node.js:411:14)
at Object.<anonymous> (/tmp/npm.5806/package/lib/utils/read-json.js:7:10)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at loadModule (node.js:283:14)
at require (node.js:411:14)
at Object.<anonymous> (/tmp/npm.5806/package/bin/read-package-json.js:9:16)
at Module._compile (node.js:462:23)
0.2.6
~~~中略
It failed
このようにインストールに失敗したので,僕がインストールに成功した方法を残します.
エラー出力にある通り,graceful-fsが必要なようです.
これはnodejsのv0.4.0以降に含まれるようです.しかし,今回は0.2.6を使用しています.
なので,これを0.4.0以降にすることにします.
$ sudo apt-get update
$ sudo apt-get install git-core curl build-essential openssl libssl-dev
$ git clone https://github.com/joyent/node.git && cd node
$ git checkout v0.5.3
$ ./configure
$ make
$ sudo make install
$ node -v
$ cd
$ curl http://npmjs.org/install.sh | sudo sh
git checkoutで使用するnodejsのバージョンを変更します.
もっと新しいバージョンが存在する場合はv0.5.3より新しいものにすると良いかもしれません.
これで無事,npmをインストールすることができます.