首先安装node
官网下载安装包,傻瓜式安装:https://nodejs.org/zh-cn/
淘宝镜像安装cnpm,
在终端输入:
npm install -g cnpm --registry=https://registry.npm.taobao.org
如果提示以下信息,说明安装失败: 
如果出现上面的信息,不要慌,依次输入下面三行命令,第三行清除一下安装缓存:
npm set registry https://registry.npm.taobao.org
npm set disturl https://npm.taobao.org/dist
npm cache clean --force

上面三行命令完成后,再次输入步骤二的命令:npm i -g cnpm --registry=https://registry.npm.taobao.org如果一切正常,输入下面的命令,查询是否安装成功:cnpm -v 如果出现下面的版本信息,说明cnpm安装成功
cnpm@5.1.1 (/usr/local/lib/node_modules/cnpm/lib/parse_argv.js)
npm@5.5.1 (/usr/local/lib/node_modules/cnpm/node_modules/npm/lib/npm.js)
node@8.9.0 (/usr/local/bin/node)
npminstall@3.2.1 (/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)
prefix=/usr/local
darwin x64 16.7.0
registry=http://registry.npm.taobao.org
如果上述步骤执行完命令后仍然出现一堆ERR!报错信息,那说明安装失败,需要一个安装的最高权限:
这时,请输入一下命令:
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose
此时会提示让你输入一个密码,即你的用户开机密码,输入回车即可,如果出现下面的信息(最下面几行)说明安装成功: 
等待安装,大约时间3-5分钟左右,看网速的快慢情况,等待出现此信息就显示安装已完毕。 
好了,输入下面的命令查询一下吧
cnpm -v
 大功告成。
|