Node.js:NVM工具的使用 nvm常用命令
NVM: Node Version Manager
Node.js的版本管理工具,可以实现多个node版本共存,并随意切换,就相当于python里面的pyenv
项目地址:https://github.com/nvm-sh/nvm/blob/master/README.md
一 安装
1.1 Mac 安装 nvm
https://github.com/nvm-sh/nvm/blob/master/README.md
1.2 Windows 安装 nvm
nvm-windows
nodist
二 使用
① nvm help 翻译解释
首先我们看下帮助文档,其实这个文档说的很明白了
nvm help Node Version Manager (v0.39.1)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(就是显示这条消息)--no-colors Suppress colored output(去掉一些颜色,显示的就是黑纸白字)nvm --version Print out the installed version of nvm(打印nvm版本)nvm install [<version>] Download and install a <version>. Uses .nvmrc if available and version is omitted.(下载指定的node版本,这个是常用命令)The following optional arguments, if provided, must appear directly after `nvm install`(这些参数必须紧紧跟在install的后面,比如vnm install -s 8.0.0):-s Skip binary download, install from source only.(自己从源码安装)-b Skip source download, install from binary only.(自己从二进制文件安装)--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(指定LTS的名字)--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(node安装完成后,自动更新到最新版的npm)--no-progress Disable the progress bar on any downloads(禁用所有的其他下载)--alias=<name> After installing, set the alias specified to the version specified. (same as: nvm alias <name> <version>)(指定一个别名)--default After installing, set default alias to the version specified. (same as: nvm alias default <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 [<version>] Modify PATH to use <version>. Uses .nvmrc if available and version is omitted.(切换版本,这是常用命令)The following optional arguments, if provided, 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.nvm exec [<version>] [<command>] Run <command> on <version>. Uses .nvmrc if available and version is omitted.(直接用某个版本运行命令)The following optional arguments, if provided, 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.(直接在某个版本上运行node脚本)The following optional arguments, if provided, 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(查看当前的node版本)nvm ls [<version>] List installed versions, matching a given <version> if provided(列出所有的已经安装的版本)--no-colors Suppress colored output--no-alias Suppress `nvm alias` outputnvm ls-remote [<version>] List remote versions available for install, matching a given <version> if provided(列出可以被下载的所有的node版本)--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 Suppress colored outputnvm 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 shell(撤销' nvm '对当前shell的影响)--silent Silences stdout/stderr output(不要打印信息)nvm alias [<pattern>] Show all aliases beginning with <pattern>(模糊查找)--no-colors Suppress colored outputnvm 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(在当前的node版本中,吧npm更新为最新)nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version(从新安装某个版本)nvm unload Unload `nvm` from shell(从shell卸载' nvm ')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 omittednvm cache dir Display path to the cache directory for nvm(显示缓存目录)nvm cache clear Empty cache directory for nvm(清空缓存目录)nvm set-colors [<color codes>] Set five text colors using format "yMeBg". Available when supported.Initial colors are:g b y r eColor codes:r/R = red / bold redg/G = green / bold greenb/B = blue / bold bluec/C = cyan / bold cyanm/M = magenta / bold magentay/Y = yellow / bold yellowk/K = black / bold blacke/W = light grey / whiteExample: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 shellnvm install node Install the latest available versionnvm use node Use the latest versionnvm install --lts Install the latest LTS versionnvm use --lts Use the latest LTS versionnvm set-colors cgYmW Set text colors to cyan, green, bold yellow, magenta, and whiteNote:to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
② NVM常用命令
1、查找版本:nvm ls 、 ls-remote
nvm ls 列出已经本地已经安装的版本
nvm ls
nvm ls-remote 列出云端所有能被安装的版本
2、安装命令: nvm install
安装指定版本的node,该命令有多个参数 ,参数应该紧跟在install之后,参数参考上面help翻译
直接vnm install加版本号即可,也可以只写主版本号,只锁定主版本号,次版本取最新
不推荐用-s 这个选项表示是从源码编译
vnm install -s 8.0.0
3、卸载命令:nvm uninstall
注意:删除某个版本时,一定要切换到其他版本,否者无法卸载
nvm uninstall 8.0.0
Uninstalled node v8.0.0
4、查看版本:nvm current
nvm current
v8.0.0
5、切换版本:nvm use
通过别名切换
nvm use default
Now using node v16.15.0 (npm v8.5.5)
通过版本切换
nvm use 8
Now using node v8.0.0 (npm v5.0.0)
5、版本别名 nvm alias
1 将8.0.0版本命名为usural
nvm alias usural 8.0.0
usural -> 8.0.0 (-> v8.0.0)
2 模糊查找 us
nvm alias us
usural -> 8.0.0 (-> v8.0.0)
3 取消别名
nvm unalias usural
Deleted alias usural - restore it with `nvm alias "usural" "8.0.0"`
6、取消vnm:nvm deactivate
执行命令后,node版本为系统原本的版本
nvm deactivate --silent
7、查看本地文件: nvm which [current | ]
nvm which current
/Users/anaymous/.nvm/versions/node/v8.0.0/bin/node
8、缓存文件:nvm cache
显示缓存文件目录
nvm cache dir
/Users/anaymous/.nvm/.cache
清除缓存文件
nvm cache clear
nvm cache cleared.
9、更改显示颜色:nvm set-colors
就是用于更改下图中红红绿绿的那些东西,纯属娱乐的命令,鼓捣玩一玩就行了
gbyre的含义,参考上面的帮助
nvm set-colors gbyre
效果:
Node.js:NVM工具的使用 nvm常用命令相关推荐
- node.js 版本控制工具 nvm 的安装和使用
目录 说明(先看说明) 卸载node.js 安装nvm nvm的使用 说明(先看说明) 这次安装,是我看了好多博客,并一一尝试,最后终于发现是其他问题...不知道对大家是否有效 有人没有卸载nods. ...
- Node.js Git Server搭建及Git常用操作笔记
Node.js Git Server搭建及Git常用操作笔记 安装Git工具即可在本地进行Git仓库的管理,如果要实现远程仓库则需要搭建Git Server.通过Node.js搭建Git Server ...
- Node.js CLI 工具最佳实践
为什么写这篇文章? 一个糟糕的 CLI 工具会让用户觉得难用,而构建一个成功的 CLI 需要密切关注很多细节,同时需要站在用户的角度,创造良好的用户体验.要做到这些特别不容易. 在这个指南中,我列出了 ...
- Node.js REST 工具 Restify
Restify 是一个 Node.JS 模块,可以让你创建正确的 REST web services.它借鉴了很多 express 的设计,因为它是 node.js web 应用事实上的标准 API. ...
- 混沌测试工具chaosblade介绍及常用命令汇总
目录 一.什么是混沌测试 二.环境搭建 三.测试指导文档 四.常用命令介绍 五.注意事项 一.什么是混沌测试 类似于"故障演练",通过构造各类异常,验证系统在碰到这些异常时是否有做 ...
- linux 查看工程用什么工具,工程师工具包-Linux常用命令及常用操作-持续更新中...
Linux系统命令相关 系统相关 date date 查看系统时间 $date 2017年 09月 18日 星期一 18:01:06 CST date -R查看系统时间,并且在时间后面加上时区的显示 ...
- ubuntu18安装node.js以及npm提速(通过nvm安装20191129)
nodejs主要2中安装方式, 1种是源代码安装,速读非常慢(我安装1小时都没完,放弃,改nvm安装) nvm方法安装nodejs: 1.先安装,nvm,即是Node版本管理器 curl -o- ht ...
- node.js开发工具--visual studio code
visual studio code,个人觉得这是开发node最好的编辑器,没有之一. 下载地址:https://code.visualstudio.com/Download 之前的版本只能开一个窗口 ...
- 工具技巧:Git 常用命令
常用操作 生成一个可供发布的压缩包 git archive 初始化用户操作 #设置提交者名字 git config --global user.name xxx #设置提交者邮箱 git config ...
最新文章
- 计算机右键功能总结,计算机基础知识:右键快捷菜单功能介绍
- 统计简单学_基本概念
- [c++]引入了头文件和动态库,为什么找不到函数实现
- python 画出决策边界_决策边界可视化,让你的分类合理有序
- idea上传项目到码云_mall前端项目的安装与部署
- 新一代开源Android渠道包生成工具Walle
- numpy 若干行和列_Numpy的轴,pandas的行和列
- 排序算法 —— 冒泡排序
- 中石油训练赛 - Edit Distance(思维+构造)
- b-2014四川电子机械职业技术学院计算机科学与技术毕业设计选题,2014届计算机科学与技术专业本科毕业设计(论文)选题指南...
- C#线程同步(1)- 临界区&Lock .
- jboss架构_检查Red Hat JBoss BRMS部署架构的规则和事件(第二部分)
- 极简单的方式序列化sqlalchemy结果集为JSON
- 专访黄翀:东方航空到底用MongoDB做了什么,技术选型为何花落MongoDB?
- HTML的基本知识(五)——无序列表、有序列表、自定义列表
- [20170203]克隆schema.txt
- ST25读FeliCa卡记录
- iText实现pdf添加文字水印
- pip 安装第三方库时各种报错It is a distutils installed project and thus we cannot accurately determine
- @Aspect不生效