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`)

Mac NVM 配置的更多相关文章

  1. Mac下配置node.js 和react-native

    最近对JS挺感兴趣的,就琢磨着在mac上配置下环境学习学习,正巧看到了Facebook的react-native,顺便配置了一下. 安装Homebrew 终端输入: ruby -e "$(c ...

  2. 在Mac上配置adb命令

    在Mac上配置adb命令 在Mac OS中使用adb命令时,应进行变量配置,步骤如下: 一.终端中输入 cd ~ 二.输入touch .bash_profile 回车 touch:如果没有,则创建文件 ...

  3. 在Mac下配置php开发环境:Apache+php+MySql

    /private/etc/apache2/httpd.conf 一.启动Apache sudo apachectl start sudo apachectl -v   可以查看到Apache的版本信息 ...

  4. iOS开发MAC下配置svn

    版本控制对于团队合作显得尤为重要,那么如何在iOS开发中进行版本控制呢?在今天的博客中将会介绍如何在MAC下配置SVN服务器,如何导入我们的工程,如何在Xcode中进行工程的checkOut和Comm ...

  5. mac下配置openfire

    下载 在浏览器中打开如下网址http://www.igniterealtime.org/downloads/index.jsp,根据你的操作系统选择对应的版本进行下载,这里我是在mac下配置的,所以选 ...

  6. Mac下配置idk

    Mac下配置java #以下进入啰嗦模式演示添加jdk7 #下载jdk7的mac版 #官网下载地址http://www.oracle.com/technetwork/java/javase/downl ...

  7. MAC OX 配置JDK环境变量

    大家在windows里面配置JDK环境变量很容易,但是如果要在mac里面配置JDK环境变量和windows里面有所不同,具体如下: 第一: mac OS里面自带jdk,不过是1.6的版本,现在很多人使 ...

  8. mac eclipse配置 tomcat

    mac由于各种软件不兼容,某些软件对于开发来说很苦恼,tomcat这个东西一直不知道怎么弄,项目都开了好几天了,一直用在虚拟机上用windows系统,但是用虚拟机明显感觉到电池待机时间更短了,所以就研 ...

  9. CAS (1) —— Mac下配置CAS到Tomcat(服务端)(转)

    tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0_65 cas版本: cas4.1.2cas-client-3.4.1 参考来源: CAS实现单点登录(SSO)经典完整教 ...

随机推荐

  1. P2280 [HNOI2003]激光炸弹(二维前缀和)

    题目描述 一种新型的激光炸弹,可以摧毁一个边长为R的正方形内的所有的目标.现在地图上有n(n≤10000)个目标,用整数xi,yi(0≤xi,yi≤5000)表示目标在地图上的位置,每个目标都有一个价 ...

  2. [ 严重 ] my网SQL注入

    RANK  80 金币    100 数据包 POST maoyan.com/sendapp HTTP/1.1Host: xxx.maoyan.comUser-Agent: Mozilla/5.0 ( ...

  3. [ 高危 ] mt网主站SQL注入

    rank  75 金币  75 等价RMB  750 数据包样式如下 POST /ajax.php HOST: xxx.meituan.com Cookie: xxx id=123&job= ...

  4. AngularJS的Scope和Digest

    Angular是一个成熟和强大的JavaScript框架.它也是一个比较庞大的框架,在熟练掌握之前,需要领会它提出的很多新概念.很多Web开发人员涌向Angular,有不少人面临同样的障碍.Diges ...

  5. BZOJ-2-4870: [Shoi2017]组合数问题 矩阵优化 DP

    就 是 要 我 们 从  n k  件 物 品 里 面 选 出 若 干 件,使 得 其 数 量 模 k 等 于 r 的 方 案 数 . dp方程 f [ i , j ] 表示前 i 件物品拿了若干件使 ...

  6. C# LnkHelper

    using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; using Syst ...

  7. java 分布式与集群的区别和联系(转)

    本文主要介绍了java分布式与集群的区别和联系,具有很好的参考价值,下面跟着小编一起来看下吧 一.先说区别: 一句话:分布式是并联工作的,集群是串联工作的. 1.分布式是指将不同的业务分布在不同的地方 ...

  8. iis和tomcat同时运行,完美解决80端口冲突问题

    背景:一台vps服务器上需要同时运行两个网站,节(老)省(板)成(扣)本,用一个服务器.一个是已经建好的官网(iis管理一键安装的PHP网站),另一个是java 项目网站(jeecg框架修改的商城项目 ...

  9. [LOJ6356]四色灯

    [LOJ6356]四色灯 题目大意: 有\(n(n\le10^9)\)个编号\(1\sim n\)的格子和\(m(m\le20)\)个按钮.每个格子有一个初始为\(0\)的数,每个按钮有一个数字\(a ...

  10. [QTree6]Query on a tree VI

    Description: 给你一棵n个点的树,编号1~n.每个点可以是黑色,可以是白色.初始时所有点都是黑色.下面有两种操作请你操作给我们看: 0 u:询问有多少个节点v满足路径u到v上所有节点(包括 ...