nvm

Posted by muchag | Node.js | 2018-05-20 (日) 13:09:41

【環境】
nvm: 0.33.11
VirtualBox グラフィカルユーザーインターフェース: 5.1.24 r117012 (Qt5.6.2)
CentOS: 7.3.1611
インストール

GitHub:creationix/nvm:README.md Installation


curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12819  100 12819    0     0  14898      0 --:--:-- --:--:-- --:--:-- 14905
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Counting objects: 267, done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 86 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 119.46 KiB | 153.00 KiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> 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

バージョンアップがあるので、毎回ここを見ること。

環境変数に登録

source ~/.bash_profile
手動登録

HORNET:CentOS6にnode.jsの最新バージョン(v8.4.0)をインストール nvmでインストール(2017-08-22)

情報確認

nvm -v

Node Version Manager

Note:  refers to any version-like string nvm understands. This includes:
  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
  - default (built-in) aliases: node, stable, unstable, iojs, system
  - custom aliases you define with `nvm alias foo`

 Any options that produce colorized output should respect the `--no-colors` option.

Usage:
  nvm --help                                Show this message
  nvm --version                             Print out the installed version of nvm
  nvm install [-s]                 Download and install a , [-s] from source. Uses .nvmrc if available
    --reinstall-packages-from=     When installing, reinstall packages installed in 
    --lts                                   When installing, only select from LTS (long-term support) versions
    --lts=                        When installing, only select from versions for a specific LTS line
    --skip-default-packages                 When installing, skip the default-packages file if it exists
    --latest-npm                            After installing, attempt to upgrade to the latest working npm on the given node version
  nvm uninstall                    Uninstall a version
  nvm uninstall --lts                       Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
  nvm uninstall --lts=            Uninstall using automatic alias for provided LTS line, if available.
  nvm use [--silent]               Modify PATH to use . Uses .nvmrc if available
    --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=                        Uses automatic alias for provided LTS line, if available.
  nvm exec [--silent]  [] Run  on . Uses .nvmrc if available
    --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=                        Uses automatic alias for provided LTS line, if available.
  nvm run [--silent]  []     Run `node` on  with  as arguments. Uses .nvmrc if available
    --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=                        Uses automatic alias for provided LTS line, if available.
  nvm current                               Display currently activated version
  nvm ls                                    List installed versions
  nvm ls                           List versions matching a given 
  nvm ls-remote                             List remote versions available for install
    --lts                                   When listing, only show LTS (long-term support) versions
  nvm ls-remote                    List remote versions available for install, matching a given 
    --lts                                   When listing, only show LTS (long-term support) versions
    --lts=                        When listing, only show versions for a specific LTS line
  nvm version                      Resolve the given description to a single local version
  nvm version-remote               Resolve the given description to a single remote version
    --lts                                   When listing, only select from LTS (long-term support) versions
    --lts=                        When listing, only select from versions for a specific LTS line
  nvm deactivate                            Undo effects of `nvm` on current shell
  nvm alias []                     Show all aliases beginning with 
  nvm alias                  Set an alias named  pointing to 
  nvm unalias                         Deletes the alias named 
  nvm install-latest-npm                    Attempt to upgrade to the latest working `npm` on the current node version
  nvm reinstall-packages           Reinstall global `npm` packages contained in  to current version
  nvm unload                                Unload `nvm` from shell
  nvm which [current | ]           Display path to installed node version. Uses .nvmrc if available
  nvm cache dir                             Display path to the cache directory for nvm
  nvm cache clear                           Empty cache directory for nvm

Example:
  nvm install 8.0.0                     Install a specific version number
  nvm use 8.0                           Use the latest available 8.0.x release
  nvm run 6.10.3 app.js                 Run app.js using node 6.10.3
  nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing to node 4.8.3
  nvm alias default 8.1.0               Set default node version on a shell
  nvm alias default node                Always default to the latest available node version on a shell

Note:
  to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
利用
バージョン確認

nvm --version
インストール可能な node.js のバージョン取得

nvm ls-remote
node.js インストール

// 安定版
nvm install stable
Downloading and installing node v10.1.0...
Downloading https://nodejs.org/dist/v10.1.0/node-v10.1.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.1.0 (npm v5.6.0)
Creating default alias: default -> stable (-> v10.1.0)

// バージョン指定
nvm install 8.0.0
npm
アップデート

npm update -g
/root/.nvm/versions/node/v10.1.0/bin/npm -> /root/.nvm/versions/node/v10.1.0/lib/node_modules/npm/bin/npm-cli.js
/root/.nvm/versions/node/v10.1.0/bin/npx -> /root/.nvm/versions/node/v10.1.0/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.10.0
added 129 packages, removed 42 packages and updated 112 packages in 6.968s
[root@localhost hoge]# npm -v
5.10.0
バージョン指定

npm install -g npm@1.4.25
バージョン確認

npm list --depth=0
参考サイト

dackdive’s blog:npm installしたパッケージの更新確認とアップデート(npm-check-updates)(2016-10-10)

CUBE SUGAR STORAGE:Node.js のパッケージマネージャ npm でバージョンを指定したインストール(2014-08-29)

参考サイト

Qiita:【俺用メモ】 CentOS6にNode.jsをインストールする nvmでインストールする場合(2018-02-10)
→インストール以外の使い方も載っている

ProgramMemo:CentOSにNode.jsをインストールする(2017-10-12)
→環境変数に登録する方法を参考にさせていただいた

Node.js | 2018-05-20 (日) 13:09:41 |

コメントはまだありません »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment