安装淘宝镜像
查看当前镜像源 npm config get registry
1.配置 npm 为淘宝镜像
npm config set registry https://registry.npm.taobao.org
2.安装 cnpm 为淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
如果还想使用原来的国外的镜像
npm config set registry https://registry.npmjs.org/
yarn安装以及使用
Yarn是facebook发布的一款取代npm的包管理工具。
1、安装yarn
npm i yarn -g / cnpm i yarn -g
yarn -v 如果能够打印出版本号 说明安装成功
初始化项目
yarn init // 同npm init,执行输入信息后,会生成package.json文件
下载模块包
npm i xxx / cnpm i xxx / yarn add xxx
安装热部署(supervisor nodemon)
全局安装命令:
npm i supervisor -g 或
cnpm i supervisor -g 或
yarn add supervisor -g
运行文件 nodemon + 文件名