一、安装npm(Nodejs)
1、下载最新版的Nodejs(这是我的网盘node-v14.16.0-x64):
链接:https://pan.baidu.com/s/1QbW62a6mPaZZHq2hCQQK1w
提取码:sbqx
复制这段内容后打开百度网盘手机App,操作更方便哦
2、直接安装即可;
C:\Users\jiguiquan>node -v v14.16.0 C:\Users\jiguiquan>npm -v 6.14.11
二、安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
查看
C:\Users\jiguiquan>cnpm -v cnpm@6.1.1 (C:\Users\jiguiquan\AppData\Roaming\npm\node_modules\cnpm\lib\parse_argv.js) npm@6.14.11 (C:\Users\jiguiquan\AppData\Roaming\npm\node_modules\cnpm\node_modules\npm\lib\npm.js) node@14.16.0 (C:\Program Files\nodejs\node.exe) npminstall@3.28.0 (C:\Users\jiguiquan\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\lib\index.js) prefix=C:\Users\jiguiquan\AppData\Roaming\npm win32 x64 10.0.19042 registry=https://r.npm.taobao.org
三、安装yarn
1、首先,我们先下载Node.js,而nodejs自带了npm;
2、通过npm安装yarn:
npm install -g yarn --registry=https://registry.npm.taobao.org
3、配置yarn国内的镜像源:
yarn config set registry https://registry.npm.taobao.org -g yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
4、检查yarn是否安装成功:
C:\Users\jiguiquan>yarn -version 1.22.10 C:\Users\jiguiquan>yarn config get registry https://registry.npm.taobao.org
大功告成!
四、Linux系统安装node与npm
1、下载Linux版本的node:
下载网址:https://nodejs.org/en/download/
我下载的是:v16.14.0
2、解压文件并放到 /usr/local 目录下:
tar -xf tar -xf node-v16.14.0-linux-x64.tar.xz mv node-v16.14.0-linux-x64 /usr/local/node
3、将node的bin目录配置到环境变量即可正常使用命令:
[root@master node]# vi /etc/profile ## 在fi和if中间行添加 export PATH=$PATH:/usr/local/node/bin ## 让新的环境变量配置生效 [root@master node]# source /etc/profile [root@master ~]# node -v v16.14.0 [root@master ~]# npm -v 8.3.1
4、配置淘宝镜像源并验证:
[root@master node]# npm config set registry https://registry.npm.taobao.org [root@master node]# npm config get registry https://registry.npm.taobao.org/
5、安装cnpm,并验证:
[root@master node]# npm install -g cnpm --registry=https://registry.npm.taobao.org [root@master node]# cnpm -v cnpm@7.1.1 (/usr/local/node/lib/node_modules/cnpm/lib/parse_argv.js) npm@6.14.16 (/usr/local/node/lib/node_modules/cnpm/node_modules/npm/lib/npm.js) node@16.14.0 (/usr/local/node/bin/node) npminstall@5.4.1 (/usr/local/node/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js) prefix=/usr/local/node linux x64 3.10.0-1160.el7.x86_64 registry=https://registry.npmmirror.com [root@master node]# cnpm config get registry https://registry.npm.taobao.org/
6、安装yarn,配置yarn源并验证
[root@master node]# npm install -g yarn --registry=https://registry.npm.taobao.org [root@master node]# yarn config set registry https://registry.npm.taobao.org -g yarn config v1.22.17 success Set "registry" to "https://registry.npm.taobao.org". Done in 0.03s. [root@master node]# yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g yarn config v1.22.17 success Set "sass_binary_site" to "http://cdn.npm.taobao.org/dist/node-sass". Done in 0.04s. [root@master node]# yarn config get registry https://registry.npm.taobao.org