やりたいこと
Node.js のバージョン管理が可能になる npm パッケージ n を利用して Node.js のバージョンをダウンロードグレードします。
環境
- OS:Ubuntu 16.04.7 LTS x86/64bit
- Node.js:v10.24.1
手順
Node.js のバージョンを v10.24.1 から v8.17.0 へダウングレードする手順になります。
n のインストール
~$ sudo npm install -g n
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
+ n@7.1.0
added 1 package from 2 contributors in 10.515s
ダウングレード可能なバージョン情報の確認
~$ n ls-remote --all
15.14.0
15.13.0
(中略)
8.17.0
8.16.2
(中略)
0.8.7
0.8.6
v8.17.0 へダウングレード
~$ n 8.17.0
installing : node-v8.17.0
mkdir : /usr/local/n/versions/node/8.17.0
mkdir: cannot create directory ‘/usr/local/n’: Permission denied
Error: sudo required (or change ownership, or define N_PREFIX)
~$ sudo n 8.17.0
installing : node-v8.17.0
mkdir : /usr/local/n/versions/node/8.17.0
fetch : https://nodejs.org/dist/v8.17.0/node-v8.17.0-linux-x64.tar.xz
installed : v8.17.0 (with npm 6.13.4)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
~$ node -v
v10.24.1
~$ PATH="$PATH"
~$ node -v
v8.17.0
参考文献