npm
修改镜像为淘宝镜像
npm config set registry https://registry.npmmirror.com
设置 npm 全局包下载路径
npm config set prefix “D:\wswsofe\nodejs\node_global”
设置 npm 缓存路径
npm config set cache “D:\wswsofe\nodejs\node_cache”
安装全局软件包
npm install -g
生产环境
在package.json文件dependencies属性下增加记录
npm install 时会自动安装该软件包
使用npm install —production或者NODE_ENV变量值为production时,安装该软件包npm install --save <Module Name>
可以简写为 npm install -S
开发环境
在package.json文件devDependencies属性下增加记录
npm install 时会自动安装该软件包
使用npm install —production或者NODE_ENV变量值为production时,不会安装该软件包npm install --save-dev <Module Name>
可以简写为 npm install -D
删除全局软件包
npm uninstall -g
删除项目中软件包
npm uninstall
查看安装的模块npm ls
查看本地已安装的包信息
npm ls tailwindcss或npm ls | grep tailwind
查看包信息
npm info tailwindcss或npm view tailwindcss
yarn
修改yarn全局安装包目录yarn config set global-folder "D:\wswSofe\nodejs\yarn_global"
修改yarn全局缓存目录yarn config set cache-folder "D:\wswSofe\nodejs\yarn_cache"
更新yarn
yarn set version latest
yarn set version from sources
查看当前使用的镜像
yarn config get registry
