node.js 自带了npm
npm是node.js的包管理器,类似于java世界的maven
npm默认的镜像源访问很慢,一般都使用国内的镜像源
方法1:安装淘宝cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
方法2: 把npm的默认镜像源改为淘宝的镜像
npm config set registry https://registry.npm.taobao.org
npm常用命令
安装所有依赖 npm install
安装单个依赖法1 npm install 依赖名 --save
安装单个依赖法2 npm -S install 依赖名
运行项目 npm run dev (vue2项目)
运行项目 npm run serve (vue3项目)
打包项目 npm run build
===========================================
Yarn 是一个可以替代npm的node.js包管理器,它比npm/cnpm安装依赖更快
官网https://yarn.bootcss.com/docs/getting-started/
npm全局安装yarn
npm install -g yarn --registry=https://registry.npm.taobao.org
npm命令对应的yarn命令
https://yarn.bootcss.com/docs/migrating-from-npm/
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
yarn常用命令
安装所有依赖 yarn install
安装某个依赖 yarn add [package]
清除本地缓存 yarn cache clean
删除一个依赖包 yarn remove [package]
运行项目 yarn run serve
打包项目 yarn run build