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 messagenvm --version                             Print out the installed version of nvmnvm 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 versionnvm uninstall <version>                   Uninstall a versionnvm 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 versionnvm ls                                    List installed versionsnvm 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) versionsnvm 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 linenvm version <version>                     Resolve the given description to a single local versionnvm 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 linenvm deactivate                            Undo effects of `nvm` on current shellnvm 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 versionnvm reinstall-packages <version>          Reinstall global `npm` packages contained in <version> to current versionnvm unload                                Unload `nvm` from shellnvm which [current | <version>]           Display path to installed node version. Uses .nvmrc if availablenvm cache dir                             Display path to the cache directory for nvmnvm cache clear                           Empty cache directory for nvmExample:nvm install 8.0.0                     Install a specific version numbernvm use 8.0                           Use the latest available 8.0.x releasenvm run 6.10.3 app.js                 Run app.js using node 6.10.3nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing to node 4.8.3nvm alias default 8.1.0               Set default node version on a shellnvm alias default node                Always default to the latest available node version on a shellNote:to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)

转载于:https://www.cnblogs.com/QianChia/p/9116794.html

Mac NVM 配置相关推荐

  1. CAS (3) —— Mac下配置CAS客户端经代理访问Tomcat CAS

    CAS (3) -- Mac下配置CAS客户端经代理访问Tomcat CAS tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0_65 nginx版本: nginx-1.9 ...

  2. 【高可用HA】Apache (4) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk

    Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk httpd版本: httpd-2.4.17 jk版本: tomcat-connectors-1.2.41 参考 ...

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

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

  4. Ionic Mac 环境配置

    2019独角兽企业重金招聘Python工程师标准>>> Ionic Mac 环境配置 ·        安装cordova之前要安装nodejs 会包含npm安装(npm是个包管理器 ...

  5. Mac VSCode配置C语言环境(可以调试)

    Mac VSCode配置C语言环境 c_cpp_properties.json tasks.json launch.json 新建一个文件夹,用vscode,然后再新建一个test.c文件. #inc ...

  6. mac开发配置手册(全)

    Mac 开发配置手册 手册内容为「如何让一部全新的 MacBook 快速完成开发环境配置」,主要面向 Web 开发者.其中的指导,在 Mavericks 和 Yosemite 上有效,其他版本系统并未 ...

  7. mac下配置进行c和matlab混编

    mac下配置进行c和matlab混编 是用mac的小伙伴有时候有没有感觉很痛苦!遇到什么问题,找相关的解决办法真心不方便,我最近在搞一段程序,要进行c和matlab的混编,可是,在matlab中输入: ...

  8. Tri Mode Ethernet MAC的配置及使用

    以太网技术是当今被广泛应用的网络技术之一,Xilinx FPGA提供了可参数化.灵活配置的千兆以太网IP Core解决方案,可以实现以太网链路层和物理层的快速接入. 关于以太网的基础知识在此不在赘述, ...

  9. Mac 终端配置 oh-my-zsh 和自动补全

    Mac 终端配置 oh-my-zsh 和自动补全以及命令高亮 安装 oh-my-zsh 在终端输入命令: sh -c "$(curl -fsSL https://raw.github.com ...

最新文章

  1. python中一共有多少个关键字-Python中关键字有多少个?
  2. C# Dynamic特性
  3. 企业必备:商业智能中应该具备的3种仪表盘(Dashboards)
  4. 千灯照碧云,越夜越星沙
  5. Services overview
  6. [转]20年来我得到的20条编程经验
  7. pycharm安装javascript插件_IDEA必备插件系列-Rainbow
  8. mysql 中文 3个字节_mysql 字节问题,中文和数字
  9. bootstrap 右自适应 左_Bootstrap自适应布局-网格系统
  10. ECMAScript 基础--原始值和引用值
  11. HTML网页设计水平线像素,细节决定成败之网页设计中1像素的妙用
  12. 如何编译运行C语言代码
  13. .NET性能系列文章二:Newtonsoft.Json vs System.Text.Json
  14. 【算法刷题】排序:CodeForces 984A,CodeForces 1132B,CodeForces 1015C
  15. c#中regex的命名空间_C# Regex类用法
  16. codeforces1438D Powerful Ksenia
  17. PC纯净版win7系统安装
  18. vi ~/.bashrc如何保存退出
  19. 全网最全的唐诗,让你了解唐诗。让你明白唐诗皎洁的月光洒到床前,迷离中疑是秋霜一片。仰头观看明月呵明月,低头乡思连翩呵连翩。国破山河在,城春草木深。感时花溅泪,恨别鸟惊心。烽火连三月,家书抵万金。白头搔
  20. gtx1660是什么级别的_GTX1660显卡首测:1060终于可以退休了!

热门文章

  1. 《设计模式详解》设计模式概述、UML
  2. 【Java从0到架构师】MyBatis - dao
  3. 【计算机网络】局域网原理与技术(局域网概述、以太网技术、高速以太网、虚拟局域网、无线局域网)
  4. 【恋上数据结构】快速排序
  5. Linux使用LVM逻辑卷 给分区扩容 不重启 热扩容
  6. [转]5个有趣的Python小知识,返回结果让人出乎意料~
  7. 中国主流的大数据分析厂商
  8. python 人脸识别调整人脸大的距离_Python 人脸识别就多简单,看这个就够了!
  9. python不等于缺陷
  10. sql在insert的同时把某个字段返回来_项目实践:后端接口统一规范的同时,如何优雅得扩展规范?...