1.nodejsをinstall
# cat /etc/redhat-release CentOS Stream release 9 # dnf install nodejs -y
2.pm2をinstall
# npm install pm2 -g npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. added 182 packages, and audited 183 packages in 5m 12 packages are looking for funding run `npm fund` for details found 0 vulnerabilities npm notice npm notice New minor version of npm available! 8.3.1 -> 8.5.5 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.5.5 npm notice Run npm install -g npm@8.5.5 to update! npm notice
3.npm8.5.5があるのでinstall
# npm install -g npm@8.5.5 added 1 package, and audited 201 packages in 19s 10 packages are looking for funding run `npm fund` for details found 0 vulnerabilities # npm version { npm: '8.3.1', node: '16.14.0', v8: '9.4.146.24-node.20', uv: '1.43.0', zlib: '1.2.11', brotli: '1.0.9', ares: '1.18.1', modules: '93', nghttp2: '1.45.1', napi: '8', llhttp: '6.0.4', openssl: '3.0.1', cldr: '40.0', icu: '70.1', tz: '2021a3', unicode: '14.0' }
4.nを入れてnodejsをupdate
# npm install -g n added 1 package, and audited 2 packages in 13s found 0 vulnerabilities # n --stable 16.14.2 # n --latest 17.8.0 # node -v v16.14.0 # n latest installing : node-v17.8.0 mkdir : /usr/local/n/versions/node/17.8.0 fetch : https://nodejs.org/dist/v17.8.0/node-v17.8.0-linux-x64.tar.xz installed : v17.8.0 (with npm 8.5.5) 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 If "node --version" shows the old version then start a new shell, or reset the location hash with: hash -r (for bash, zsh, ash, dash, and ksh) rehash (for csh and tcsh)
5.まだ古いversionを返す
# node -v v16.14.0 # n ls node/17.8.0
6.new login
7.結果 npm -> 8.5.5, node -> 17.8.0
# node -v v17.8.0 # npm version { npm: '8.5.5', node: '17.8.0', v8: '9.6.180.15-node.16', uv: '1.43.0', zlib: '1.2.11', brotli: '1.0.9', ares: '1.18.1', modules: '102', nghttp2: '1.47.0', napi: '8', llhttp: '6.0.4', openssl: '3.0.2+quic', cldr: '40.0', icu: '70.1', tz: '2021a3', unicode: '14.0', ngtcp2: '0.1.0-DEV', nghttp3: '0.1.0-DEV' }
ただし、確認は別のterminalから行う。
linkを実行したterminalでnpm versionで確認するとnpm: ‘8.3.1’,と表示する。
8.npm update
# npm update -g npm changed 14 packages, and audited 201 packages in 19s 10 packages are looking for funding run `npm fund` for details found 0 vulnerabilities # npm update -g npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. changed 198 packages, and audited 385 packages in 4m 18 packages are looking for funding run `npm fund` for details found 0 vulnerabilities #
9.古いGlobalパッケージの確認
# npm outdated -g #
10.”Please upgrade to version 7 or higher.”とあるので、最新版のuuidをglobal install
# npm install -g uuid # npm list -g --depth=0 /usr/local/lib tqq corepack@0.10.0 tqq n@8.1.0 tqq npm@8.5.5 tqq pm2@5.2.0 mqq uuid@8.3.2