1、NVM 简介

  • NVM(node version manager)是一个可以让你在同一台机器上安装和切换不同版本 node 的工具。

  • GitHub 地址

2、NVM 环境配置

2.1 安装 NVM

  • 如果系统没有安装 git 的话,需先安装 git

  • 在终端输入以下命令安装 NVM。

    # 安装 NVM
    $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  • 安装完成后在终端中输入以下命令配置环境变量。

    # 打开环境变量配置文件
    $ vim ~/.bash_profile
  • 在 .bash_profile 文件中添加一下字段。

    source ~/.bashrc
  • 保存文件退出,在终端中输入以下命令使配置生效。

    # 使环境变量配置生效
    $ source ~/.bash_profile

2.2 NVM 常用命令

  • 常用命令

    # 查看该系统已经安装的版本,这个命令也能看到当前使用的是哪个版本
    $ nvm ls # 列出全部可以安装的版本号
    $ nvm ls-remote # 安装指定版本
    $ nvm install [version]
    $ nvm install v10.2.0 # 切换到指定版本,切换效果是全局的
    $ nvm use [version]
    $ nvm use v10.2.0 # 查看当前使用的版本
    $ nvm current
    Note: <version> 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] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available
    --reinstall-packages-from=<version> When installing, reinstall packages installed in <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 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 <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 [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available
    --lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
    --lts=<LTS name> Uses automatic alias for provided LTS line, if available.
    nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available
    --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 [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available
    --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
    nvm ls List installed versions
    nvm ls <version> List versions matching a given <version>
    nvm ls-remote List remote versions available for install
    --lts When listing, only show LTS (long-term support) versions
    nvm ls-remote <version> List remote versions available for install, matching a given <version>
    --lts When listing, only show LTS (long-term support) versions
    --lts=<LTS name> When listing, only show versions for a specific LTS line
    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
    nvm alias [<pattern>] Show all aliases beginning with <pattern>
    nvm alias <name> <version> Set an alias named <name> pointing to <version>
    nvm unalias <name> Deletes the alias named <name>
    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
    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`)

最新文章

  1. PHP环境的搭建(Apache)
  2. Used Query
  3. IDEA Generating project in Batch mode
  4. CF451A Game With Sticks 水题
  5. 解决jQuery ajax跨域问题,Google、IE、Firefox亲测有效
  6. C#中override和overload的区别
  7. 结构类模式(一):适配器(Adapter)
  8. eclipse实现JavaWeb应用增量打包
  9. (转)PHP下编码转换函数mb_convert_encoding与iconv的使用说明
  10. axd与ashx区别
  11. MVC中各类文件
  12. 向php提交数据及json
  13. Linux tomcat 去除项目名端口号直接用ip或者域名访问网站
  14. TensorLayer官方中文文档1.7.4:API – 可视化
  15. Future学习
  16. A Diversity-Promoting Objective Function for Neural Conversation Models论文阅读
  17. 关于 mysql2 -v &#39;0.3.21&#39;(CentOS7.3)
  18. VS Code常用快捷键
  19. Postgresql 数据库错误修复v0.1
  20. Gym101889E. Enigma(bfs+数位)

热门文章

  1. 在Idea中添加自定义补全代码设置(Main方法为例)
  2. POJ 2418 Hardwood Species 【Trie树】
  3. C# 使用 Proxy 代理请求资源
  4. XamarinAndroid组件教程RecylerView适配器动画动画种类
  5. Flask 三方组件 WTForms
  6. hdu2087 剪花布条
  7. xpath分析 html文件抽正文的过程
  8. GMA Round 1 最大值
  9. fzu1050 Number lengths(对数公式)
  10. Uva11582 Colossal Fibonacci Numbers!(同余模定理+快速幂)