1.nvmのinstall
2.nodeの現在のversion
# node -v v18.1.0
3.nvmのdownload
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 15037 100 15037 0 0 27540 0 --:--:-- --:--:-- --:--:-- 27489 => Downloading nvm from git to '/root/.nvm' => Cloning into '/root/.nvm'... remote: Enumerating objects: 355, done. remote: Counting objects: 100% (355/355), done. remote: Compressing objects: 100% (302/302), done. remote: Total 355 (delta 39), reused 169 (delta 28), pack-reused 0 Receiving objects: 100% (355/355), 221.36 KiB | 3.07 MiB/s, done. Resolving deltas: 100% (39/39), done. * (HEAD detached at FETCH_HEAD) master => Compressing and cleaning up git repository => Appending nvm source string to /root/.bashrc => Appending bash_completion source string to /root/.bashrc => You currently have modules installed globally with `npm`. These will no => longer be linked to the active version of Node when you install a new node => with `nvm`; and they may (depending on how you construct your `$PATH`) => override the binaries of modules installed with `nvm`: /usr/local/lib tqq corepack@0.10.0 tqq eslint@8.15.0 tqq ganache@7.1.0 tqq n@8.2.0 tqq npm-upgrade@3.1.0 tqq pm2@5.2.0 mqq uuid@8.3.2 => If you wish to uninstall them at a later point (or re-install them under your => `nvm` Nodes), you can remove them from the system Node as follows: $ nvm use system $ npm uninstall -g a_module => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion #
3.~/.bashrcに変更が加えられている
ここで、nodeへのpathを切り替えている
# cat ~/.bashrc # ./bashrc ・・・ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion # source ~/.bashrc #