LoginSignup
3
3

More than 5 years have passed since last update.

CentOS6で、npm の iconvがインストール出来ない

Posted at

gccのアップデートを行えば解決できた。

具体的には、gcc 4.4.x => gcc 4.8.x にアップデートを行うことで解決。

他にも、以下のようなエラーが出るケースでは、gccをアップデートする事で解決出来ると思う。

pm ERR! iconv@2.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the iconv@2.2.1 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs iconv
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls iconv
npm ERR! There is likely additional logging output above.

原因

npm install iconv において、build時にgccを利用するのだが、そのgccのライブラリバージョンが低いのが問題だったって訳。

対応方法

既存のgccを削除

yum remove gcc

gccのリポジトリを取得して、gcc関連をインストール

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils
yum install devtoolset-2-gcc-c++ devtoolset-2-gcc-gfortran

後はパスを通すだけ。

# ローカルユーザならばこちら
vi ~/.bashrc
# 全体に反映するならこっち。
vi /etc/bashrc

# 最終行に追加
source /opt/rh/devtoolset-2/enable

環境読み込みして完了。

. ~/.bashrc

3
3
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
3
3