windows下升级node
官网地址:Node.js
去官网下载最新msi文件 覆盖安装,windows不支持 n
查看版本:node -v
linux下更新node到最新版本
第一执行(root权限):npm install -g n
第二执行(root权限):n latest
n
常用的命令有:n
会列出所有安装的版本供你切换n latest
安装最新版本n stable
安装最新稳定版n lts
安装最新长期支持版本n rm [版本号]
删除某一版本n -h
帮助命令n [版本号]
安装指定版本node
更新后可见
installing : node-v12.17.0
mkdir : /usr/local/n/versions/node/12.17.0
fetch : https://nodejs.org/dist/v12.17.0/node-v12.17.0-linux-x64.tar.gz
installed : v12.17.0 (with npm 6.14.4)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
配置node环境:
vim /etc/profile
在proflie文件最后加入:
export NODE_HOME=/usr/local/n/versions/node/12.17.0
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
执行:source profile
查看当前npm源
npm config get registry
>http://registry.npmjs.org/
修改npm源(设置为淘宝npm源)
npm config set registry https://registry.npm.taobao.org
npm淘宝镜像(后期将npm改成cnpm)
直接用npm安装vue-cli会特别慢,在安装vue-cli之前可以先安装一个淘宝镜像。之后的安装命令还是和npm一样,只不过把npm改成cnpm,但速度已经不是一个等级的了
npm install -g cnpm --registry=https://registry.npm.taobao.org