EC2上のCentOSにnode.jsのsocket.ioをインストールしようとした際のエラー

npmでsocket.ioがインストールできない!と思ったらデフォルトのtar (GNU tar) 1.15.1だとダメだったというだけのメモ。

$ npm install socket.io
npm ERR! Failed unpacking /tmp/npm-1319403120027/1319403120088-0.7213427403476089/tmp.tgz
npm ERR! couldn't unpack /tmp/npm-1319403120027/1319403120088-0.7213427403476089/tmp.tgz to /tmp/npm-1319403120027/1319403120088-0.7213427403476089/contents
npm ERR! error installing socket.io-client@0.8.5 Error: `tar "-zmvxpf" "/tmp/npm-1319403120027/1319403120088-0.7213427403476089/tmp.tgz" "-o"`
npm ERR! error installing socket.io-client@0.8.5 failed with 2
npm ERR! error installing socket.io-client@0.8.5     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/tar.js:219:20)
npm ERR! error installing socket.io-client@0.8.5     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing socket.io-client@0.8.5     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! error installing socket.io@0.8.5 Error: `tar "-zmvxpf" "/tmp/npm-1319403120027/1319403120088-0.7213427403476089/tmp.tgz" "-o"`
npm ERR! error installing socket.io@0.8.5 failed with 2
npm ERR! error installing socket.io@0.8.5     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/tar.js:219:20)
npm ERR! error installing socket.io@0.8.5     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing socket.io@0.8.5     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! Error: `tar "-zmvxpf" "/tmp/npm-1319403120027/1319403120088-0.7213427403476089/tmp.tgz" "-o"`
npm ERR! failed with 2
npm ERR!     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/tar.js:219:20)
npm ERR!     at ChildProcess.emit (events.js:67:17)
npm ERR!     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>   
npm ERR!
npm ERR! System Linux 2.6.18-194.el5xen
npm ERR! command "node" "/usr/local/bin/npm" "install" "socket.io"
npm ERR! cwd /root/src/chat-node
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.101
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /root/src/chat-node/npm-debug.log
npm not ok


まさにこのとおり。

What does tar --version output? If it's gnutar 1.15 or so, you need to upgrade to something more modern. I've been told by other CentOS users that 1.15.1 is the newest rpm available, so you may need to build from source.

https://github.com/isaacs/npm/issues/1559


デフォルトのバージョンは1.15.1

$ tar --version
tar (GNU tar) 1.15.1

最新の1.26をダウンロード&インストール。

$ wget http://ftp.gnu.org/gnu/tar/tar-1.26.tar.gz
$ tar -xzvf tar-1.26.tar.gz
$ cd tar-1.26
$ ./configure FORCE_UNSAFE_CONFIGURE=1
$ make 
$ make install

できたできた

$ npm install socket.io
socket.io@0.8.5 ./node_modules/socket.io 
├── redis@0.6.6
├── policyfile@0.0.4
└── socket.io-client@0.8.5