はじめに
Node.jsの小規模開発ならXserverで出来たら、コスパいいなと思い、XserverにNode.jsを入れてみました。
結局のところ、Xserverで開発はしないような気もしますが、忘備録として残しておきます。
XserverにSSH接続する
サーバーパネルの「SSH設定」を選択する。

SSH設定タブで「ONにする」を選択して「設定する」を押下。

公開鍵用認証鍵ペアの生成タブでパスフレーズを適当に設定して「確認画面へ進む」を押下。

生成するを押下すると、「****.key」というファイルがダウンロードされるので保管しておく。

Teratermで接続する
Teratermを起動して、「設定」→「SSH認証」を押下。

「デフォルトユーザ名を使用」の欄にアカウント名(****.keyの****部分)を入力する。
認証方式は「RSA/DSA/ECDSA/ED25519鍵を使う」にチェックして右の参照ボタンから先ほどダウンロードした「****.key」を選択する。

「ファイル」→「新しい接続」を押下。

ホスト名「sv****.xserver.jp」(****はサーバー番号)を入力し、TCPポートを「10022」とする。

公開鍵用認証鍵ペアを作成した際のパスフレーズを入力する。

次のような文字が表示されていれば接続完了。

nodebrewのインストール
以下のコマンドを順に実行する。
wget git.io/nodebrew
perl nodebrew setup
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
nodebrew -v
nodebrewのバージョン情報が出力されていればOK。自分の場合、問題なく実施できた。
Node.jsのインストール
以下のコマンドを順に実行する。
nodebrew install-binary latest
nodebrew list
自分の環境では「v18.5.0」が表示されたので、以下のコマンドを実行。
nodebrew use v18.5.0
node -v
ここで問題発生。以下の画像のようにエラーが出力された。

原因は良くわからないが、ひとまずは過去のバージョンに戻してインストールしてみる。
nodebrew install v16.5.0
nodebrew use v16.5.0
node -v
「v16.5.0」と表示された。これで「Node.js」がXserver上で使えるようになった。
最後に
過去バージョンを入れたのはいいものの、最新版が入れられていないのはそれでいいのかという。。。
コメント