安装node
centOS 通过yum 安装nodejs和npm
官方查看有哪些版本,查找自己想要的nodejs源
先安装源:
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
然后:
yum -y install nodejs
通过:node -v 和npm -v 查看版本,说明安装成功
替换为淘宝NPM镜像
首先我们可以查看原本的镜像地址:
npm get registry
https://registry.npmjs.org/
然后替换成淘宝的:
npm config set registry http://registry.npm.taobao.org/
如果想恢复原来的镜像地址:
npm config set registry https://registry.npmjs.org/
如果用淘宝定制的cnpm工具来代替默认的npm:
npm install -g cnpm --registry=https://registry.npm.taobao.org
Yarn是facebook发布的一款取代npm的包管理工具。
yarn的安装:
下载node.js,使用npm安装
npm install -g yarn
查看版本:yarn --version
安装node.js,下载yarn的安装程序:
提供一个.msi文件,在运行时将引导您在Windows上安装Yarn
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
配置代理
npm config set https-proxy http://${ip}:${port}
npm config set proxy http://${ip}:${port}
yarn config set https-proxy http://${ip}:${port}
yarn config set proxy http://${ip}:${port}