1
0

More than 3 years have passed since last update.

Docker上のCentOSでnodebrewを入れる

Last updated at Posted at 2020-03-03

はじめに

Centosにnodebrewを入れる記事はたくさん存在するのですが、
Dockerでやった時に詰まったので個人的なメモがてら残しておきます。

環境

  • docker
$ docker --version
Docker version 19.03.5, build 633a0ea
  • Dockerfile
FROM centos:centos7

やったこと

1. 従来の記事を読んでinstall

$ curl -L git.io/nodebrew | perl - setup

↓ 悲しみのエラー

Can't exec "which": No such file or directory at - line 927.
Can't exec "which": No such file or directory at - line 927.
Need curl or wget at - line 927.

whichがないと言われinstall出来ない。
どうやら、centos:centos7にはwhichなどがない模様。

2. whichをinstall

$ yum -y install which

3. 再びnodebrewをinstall

$ curl -L git.io/nodebrew | perl - setup

↓ install 完了!

Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================

3. 欲しいバージョンを入れて使用

$ /root/.nodebrew/current/bin/nodebrew install v12.16.1
$ /root/.nodebrew/current/bin/nodebrew use v12.16.1

今回は、nodeのv12系を入れたかったので、こんな感じでinstallしました。

余談ですがdocker等でサーバを立てたりする時にpassを通すと後から確認する時困ることが多いので、僕はフルパスで起動するようにしています。
もちろん、自分のmacではしっかりpassを通してます。

4. まとめ

$ yum -y install which
$ curl -L git.io/nodebrew | perl - setup
$ /root/.nodebrew/current/bin/nodebrew install v12.16.1
$ /root/.nodebrew/current/bin/nodebrew use v12.16.1
$ /root/.nodebrew/current/bin/node --version

↓ nodeが使えることを確認

v12.16.1

おわりに

dockerを触っていると、環境構築ばかり行うので詰まった時とかはqiitaに残しておくのが必要ですね...!

1
0
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
1
0