2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBMi テスト用のオレオレnode.js環境を作る

2
Posted at

IBM i の yum install nodejsXX で Node.js をインストールすることはできますが、これは IBM i のグローバル環境 /QOpenSys/pkgs/lib/nodejsXX にインストールされてます。
例えば npm install hoge -g で試したいパッケージをグローバル・インストールで試したい時に、全体に影響してしまうので、自分のテスト用のオレオレ node.js 環境を作る方法です。ただしあくまでも開発やテスト用だと思って下さい。

yum の node.js 環境を複製

まだ Node.js が IBM i にインストールされていない場合は yum で Node.js バージョンXXをインストールします。ACS使っても勿論OKです。

# Node.jsがインストールされているか?
yum list installed | grep nodejs

# Node.jsをインストール
yum install nodejsXX

適当なディレクトリを作成して、グローバルの Node.js を複製します。

# ディレクトリ作成
mkdir -p ~/opt/nodejs

# ディレクトリへ移動
cd ~/opt/nodejs

# 複製
cp -rp /QOpenSys/pkgs/lib/nodejsXX ./

corepack の有効化

npx や yarn などを使う場合は corepack を有効化します。

# ディレクトリへ移動
cd ~/opt/nodejs/nodejsXX/bin/

# CorePack展開
./corepack enable

# コマンド一覧
lrwxrwxrwx 1 qsys    0        90 2025-07-15 17:24 corepack -> ../lib/node_modules/corepack/dist/corepack.js*
-rwxr-xr-x 1 qsys    0 179177455 2025-05-13 06:40 node*
lrwxrwxrwx 1 qsys    0        76 2025-07-15 17:24 npm -> ../lib/node_modules/npm/bin/npm-cli.js*
lrwxrwxrwx 1 qsys    0        76 2025-07-15 17:24 npx -> ../lib/node_modules/npm/bin/npx-cli.js*
lrwxrwxrwx 1 ushiday 0        82 2025-09-20 18:07 pnpm -> ../lib/node_modules/corepack/dist/pnpm.js*
lrwxrwxrwx 1 ushiday 0        82 2025-09-20 18:07 pnpx -> ../lib/node_modules/corepack/dist/pnpx.js*
lrwxrwxrwx 1 ushiday 0        82 2025-09-20 18:07 yarn -> ../lib/node_modules/corepack/dist/yarn.js*
lrwxrwxrwx 1 ushiday 0        88 2025-09-20 18:07 yarnpkg -> ../lib/node_modules/corepack/dist/yarnpkg.js*

専用オレオレ Node.js にパスを通す

あとは、CLI で使うために PATH を通します

#---------------------------
# ~/.profile 
#---------------------------
PATH=~/opt/nodejs/nodejsXX/bin:$PATH

以上です。
ただ、yum update とは切り離されるのとバージョンも固定されますので、あくまでも オレオレ です。

2
1
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?