从零到一保姆级前后端分离权限系统
本文是windows系统,所以安装nvm-windows。官网
nvm 是 Node Version Manager 的缩写,它是一个用于管理 Node.js 版本的工具。通过使用 nvm,您可以轻松地在同一台计算机上安装和切换不同的 Node.js 版本。
安装步骤:以windows10系统为例 注意:nvm的安装目录不能有汉字和空格,否则会报错 注意:电脑之前安装过nodejs的,不需要卸载,nvm在安装的过程中会提示,是否把电脑之前安装过的nodejs交给nvm来管理,点击【是】就可以了
一、安装步骤
1、从官网中下载安装包。下载下来是个压缩包,解压后运行里面的exe文件即可。
2、运行exe文件。
3、配置nvm的安装位置,nvm的安装目录不能有汉字和空格,否则会报错
4、设置node的symlink文件夹位置。可以是你之前安装node的文件夹,也可以是新建的node管理文件夹。
5、如果在安装nvm之前,电脑上就已经安装有node的,就会弹窗询问你是否用nvm管理已经存在的node版本。一定要选‘是’,这个弹窗可能会出现好几次,都点是。
6、nm v 查看是否安装成功,如下则安装成功!

7、修改settings.txt 在你安装的nvm目录下找到settings.txt文件,打开settings.txt文件后,加上下面两行代码:
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
目的是将npm镜像改为淘宝的镜像,可以提高下载速度
二、使用NVM
1、检查nvm是否安装成功。使用管理员权限打开一个命令行。输入nvm v,会显示nvm的版本号,有则表示安装成功
2、nvm常用命令
2.1、安装指定版本的node:nvm install 版本号
nvm install 12.18.3
2.2、使用指定版本的node:nvm use 版本号
nvm use 12.18.3
2.3、查看当前电脑上已经安装的全部node版本
正在使用中的版本号前有个星号
nvm ls
2.4、查看可用的(可下载的)全部node版本
nvm ls available
2.5、使用淘宝node镜像:nvm node_mirror
nvm node_mirror https://npm.taobao.org/mirrors/node/
2.6、使用淘宝npm镜像:nvm npm_mirror
nvm npm_mirror https://npm.taobao.org/mirrors/npm/
2.7、设置安装node 的位数(x32 | x64):nvm arch [32|64]
nvm arch 64
全部步骤
Microsoft Windows [版本 10.0.19045.3570]
(c) Microsoft Corporation。保留所有权利。
C:\Users\Administrator>nvm -v
Running version 1.1.7.
Usage:
nvm arch : Show if node is running in 32 or 64 bit mode.
nvm install <version> [arch] : The version can be a node.js version or "latest" for the latest stable version.
Optionally specify whether to install the 32 or 64 bit version (defaults to system arch).
Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm version : Displays the current running version of nvm for Windows. Aliased as v.
C:\Users\Administrator>npm -v
8.19.4
C:\Users\Administrator>node -v
v16.20.0
C:\Users\Administrator>node_mirror: https://npm.taobao.org/mirrors/node/
'node_mirror:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\Administrator>nvm npm_mirror https://npm.taobao.org/mirrors/npm/
C:\Users\Administrator>nvm npm_mirror https://npm.taobao.org/mirrors/npm/
C:\Users\Administrator>nvm node_mirror https://npm.taobao.org/mirrors/node/
C:\Users\Administrator>nvm install 12.18.3
Downloading node.js version 12.18.3 (64-bit)...
Complete
Creating E:\server\nvm\temp
Downloading npm version 6.14.6... Complete
Installing npm v6.14.6...
Installation complete. If you want to use this version, type
nvm use 12.18.3
C:\Users\Administrator>nvm use 12.18.3
Now using node v12.18.3 (64-bit)
C:\Users\Administrator>nvm ls
16.20.0
* 12.18.3 (Currently using 64-bit executable)
C:\Users\Administrator>nvm arch 64
Default architecture set to 64-bit.
C:\Users\Administrator>
3、使用 nvm 管理版本(nvm常用命令)
nvm install latest 安装最新版本node.js
nvm use 版本号 使用某一具体版本,例如 :nvm use 14.3.0
nvm list 列出当前已安装的所有版本
nvm ls 列出当前已安装的所有版本
nvm uninstall 版本号 卸载某一具体版本,例如:nvm use 14.3.0
nvm ls-remote Mac版本中,列出全部可以安装的node版本
nvm ls available windows版本,列出全部可以安装的node版本
nvm current 显示当前的版本
nvm alias 给不同的版本号添加别名
nvm unalias 删除已定义的别名
nvm reinstall-packages 在当前版本node环境下,重新全局安装指定版本号的npm包
注意:windows10的系统,nvm安装成功后,会自动的把对应的环境变量添加到系统上注意:安装完成后,在CMD中运行 nvm, 提示 【nvm不是内部或外部命令,也不是可运行的程序或批处理文件。】就是没有配置对应的环境变量,如果环境变量配置了,电脑重启即可解决
4、其他更多nvm命令
nvm arch [32|64]:显示node是运行在32位还是64位模式。指定32或64来覆盖默认体系结构。
-nvm install [arch]:该可以是node.js版本或最新稳定版本latest。(可选[arch])指定安装32位或64位版本(默认为系统arch)。设置[arch]为all以安装32和64位版本。在命令后面添加–insecure,可以绕过远端下载服务器的SSL验证。
nvm list [available]:列出已经安装的node.js版本。可选的available,显示可下载版本的部分列表。这个命令可以简写为nvm ls [available]。
nvm on:启用node.js版本管理。
nvm off:禁用node.js版本管理(不卸载任何东西)
nvm proxy [url]:设置用于下载的代理。留[url]空白,以查看当前的代理。设置[url]为none删除代理。
nvm node_mirror [url]:设置node镜像,默认为https://nodejs.org/dist/.。可以设置为淘宝的镜像https://npm.taobao.org/mirrors/node/
nvm npm_mirror [url]:设置npm镜像,默认为https://github.com/npm/npm/archive/。可以设置为淘宝的镜像https://npm.taobao.org/mirrors/npm/
nvm uninstall :卸载指定版本的nodejs。
nvm use [version] [arch]:切换到使用指定的nodejs版本。可以指定32/64位[arch]。
-nvm use :将继续使用所选版本,但根据提供的值切换到32/64位模式
nvm root [path]:设置 nvm 存储node.js不同版本的目录 ,如果未设置,将使用当前目录。
-nvm version:显示当前运行的nvm版本,可以简写为nvm v