Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9225

CentOS 6.10でNode.js 14.16(LTS)を使用可能にする(gitアップデート, nvmインストール編)

$
0
0

現状

サポートの終わったCentOS6.10のレガシーなサーバーのネイティブ環境でNode.jsがどうしても使いたい。
とりあえず nvm経由でインストールしてみる。

nvmインストール

こちらから

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

すると

=> Unknown option: -c
usage: git [--version][--exec-path[=GIT_EXEC_PATH]] [--html-path][-p|--paginate|--no-pager] [--no-replace-objects][--bare][--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
           [--help] COMMAND [ARGS]
Failed to clone nvm repo. Please report this!

どうやらgit commandに -cがないようなのでgit --versionを確認

$ git --version
git version 1.7.1

古すぎるのでアップデートします。

gitのアップデート

$ sudo yum remove git
$ sudo yum install gcc curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
$ wget https://www.kernel.org/pub/software/scm/git/git-2.2.0.tar.gz
$ tar-zxf git-2.2.0.tar.gz
$ cd git-2.2.0
$ make prefix=/usr/local all
$ make prefix=/usr/local install

しばらく待つと, 終わるので git --versionを確認

rm-f"$execdir/$p"&&\test-z""&&\ln"$execdir/git""$execdir/$p" 2>/dev/null ||\ln-s"git""$execdir/$p" 2>/dev/null ||\cp"$execdir/git""$execdir/$p"||exit;\done&&\remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps"&&\for p in$remote_curl_aliases;do\rm-f"$execdir/$p"&&\test-z""&&\ln"$execdir/git-remote-http""$execdir/$p" 2>/dev/null ||\ln-s"git-remote-http""$execdir/$p" 2>/dev/null ||\cp"$execdir/git-remote-http""$execdir/$p"||exit;\done&&\
        ./check_bindir "z$bindir""z$execdir""$bindir/git-add"$ git --version-bash: /usr/bin/git: そのようなファイルやディレクトリはありません

と怒られる。

https://qiita.com/sirone/items/2e233ab9697a030f1335
にある通り,

gitを実行しようとした時に「そんなファイルはないよ!」と指摘されるファイルパスと、whichtypeで確認したときのファイルパスで、ズレが生じるケースがあるようです。

$ git --version-bash: /usr/bin/git: No such file or directory

$ which git
/usr/local/bin/git

$ type git
git is /usr/local/bin/git

この場合、bashの組み込みコマンドである hashコマンドで解決することが出来る、とのことでした。

$ hash-r$ git --version
git version 2.2.0

インストールが確認できた.

nvmインストール(2回目)

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

vimで.bashrcに追記

export NVM_DIR="$([-z"${XDG_CONFIG_HOME-}"]&&printf %s "${HOME}/.nvm"||printf %s "${XDG_CONFIG_HOME}/nvm")"[-s"$NVM_DIR/nvm.sh"]&&\."$NVM_DIR/nvm.sh"# This loads nvm

バージョンを確認

$ nvm -v
0.37.2

nvmがインストールできました。

LTSバージョンをnvm経由でインストール(2021年3月現在)

$ nvm install--lts
Installing latest LTS version.
Downloading and installing node v14.16.0...
Downloading https://nodejs.org/dist/v14.16.0/node-v14.16.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.16.0 (npm v)
Creating default alias: default -> lts/*(-> v14.16.0)

ここでnodeコマンドを打つと,

$ node
node: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by node)
[webadmin@www6108ug ~]$ node -v
node: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by node)
node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by node)

どうやらlibc, libstdc++などが古すぎて対応しておらず nodeコマンドが使えないようです。

これを解決するにはgccのビルドと必要なライブラリをインストールする必要があります。
これに関してはまた次回書きます。

参考


Viewing all articles
Browse latest Browse all 9225

Trending Articles