Baris Perintah nvm-sh (Linux/MacOS/WSL)
<version> mengacu pada string seperti versi apa pun yang dipahami nvm. Ini termasuk:
- Nomor versi lengkap atau sebagian, opsional diawali dengan "v" (0.10, v0.1.2, v1)
- Alias default (bawaan): node, stable, unstable, iojs, system
- Alias kustom yang ditentukan dengan
nvm alias foo
Opsi apa pun yang menghasilkan output berwarna harus menghormati opsi --no-colors.
Penggunaan Baris Perintah nvm-sh:
bash
nvm --help Show this message
--no-colors Disable colors
nvm --version Print out the installed nvm version
nvm install [<version>] Download and install <version>. Uses .nvmrc if available and version is omitted.
The following optional arguments must appear directly after `nvm install`:
-s Skip binary download, install from source only.
-b Skip source download, install from binary only.
--reinstall-packages-from=<version> When installing, reinstall packages from <node|iojs|node version number>.
--lts When installing, only select from LTS (long-term support) versions.
--lts=<LTS name> When installing, only select from versions for a specific LTS line.
--skip-default-packages When installing, skip default-packages file if it exists.
--latest-npm After installation, attempt to upgrade to the latest working npm on the given node version.
--no-progress Disable the progress bar on any downloads.
--alias=<n> After installation, set the alias specified to the version specified. (same as: nvm alias <n> <version>)
--default After installation, set default alias to the version specified. (same as: nvm alias default <version>)
--save After installation, write the specified version to .nvmrc.
nvm uninstall <version> Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.
nvm use [<version>] Modify PATH to use <version>. Uses .nvmrc if available and version is omitted.
The following optional arguments must appear directly after `nvm use`:
--silent Silences stdout/stderr output
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
--save Write the specified version to .nvmrc.
nvm exec [<version>] [<command>] Run <command> on <version>. Uses .nvmrc if available and version is omitted.
The following optional arguments must appear directly after `nvm exec`:
--silent Silences stdout/stderr output
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm run [<version>] [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available and version is omitted.
The following optional arguments must appear directly after `nvm run`:
--silent Silences stdout/stderr output
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version of Node
nvm ls [<version>] List installed versions, matching a given <version> if provided
--no-colors Disable colors
--no-alias Suppress `nvm alias` output
nvm ls-remote [<version>] List remote versions available for install, matching a given <version> if provided
--lts When listing, only show LTS (long-term support) versions
--lts=<LTS name> When listing, only show versions for a specific LTS line
--no-colors Disable colors
nvm version <version> Resolve the given description to a single local version
nvm version-remote <version> Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts=<LTS name> When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of `nvm` on current shell
--silent Silences stdout/stderr output
nvm alias [<pattern>] Show all aliases beginning with <pattern>
--no-colors Disable colors
nvm alias <n> <version> Set an alias named <n> pointing to <version>
nvm unalias <n> Deletes the alias named <n>
nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version
nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version
nvm unload Unload `nvm` from shell
nvm which [current | <version>] Display path to installed node version. Uses .nvmrc if available and version is omitted.
--silent Silences stdout/stderr output when a version is omitted
nvm cache dir Display path to the cache directory for nvm
nvm cache clear Empty the cache directory for nvm
nvm set-colors [<color codes>] Set five text colors using format "yMeBg". Available when supported, initial colors are:
bygre
Color codes:
r/R = red / bold red
g/G = green / bold green
b/B = blue / bold blue
c/C = cyan / bold cyan
m/M = magenta / bold magenta
y/Y = yellow / bold yellow
k/K = black / bold black
e/W = light grey / whiteContoh Perintah nvm-sh:
nvm install 8.0.0Instal nomor versi tertentunvm use 8.0Gunakan versi 8.0.x terbarunvm run 6.10.3 app.jsJalankan app.js menggunakan node 6.10.3nvm exec 4.8.3 node app.jsJalankannode app.jsmenggunakan node 4.8.3nvm alias default 8.1.0Tetapkan versi node default pada shellnvm alias default nodeSelalu default ke versi node terbaru yang tersedia pada shellnvm install nodeInstal versi terbaru yang tersedianvm use nodeGunakan versi terbarunvm install --ltsInstal versi LTS terbarunvm use --ltsGunakan versi LTS terbarunvm set-colors cgYmWTetapkan warna teks ke cyan, hijau, kuning tebal, magenta, dan putih
TIP
Untuk menghapus, menghapus, atau mencopot pemasangan nvm, cukup hapus folder $NVM_DIR (biasanya ~/.nvm)