记录下Node下npm和yarn相关命令
Node下npm和yarn命令对比
最近在搞一个前端项目是环境出了问题,手贱将全局包给删了,导致好些包在使用时出现问题,这里干脆将npm和yarn的相关命令整理一下,方便以后在使用时方便查阅。
npm yarn pnpm 描述 npm installyarn installpnpm install安装项目包 npm install react --saveyarn add reactpnpm add react添加包 npm uninstall react --saveyarn remove reactpnpm remove react删除包 npm install react --save-devyarn add react --devpnpm add react -D添加包在开发依赖中 npm update --saveyarn upgrade更新包 安装检查包 npm install -g npm-check-updates
-ncu# 查看更新
-ncu -a# 更新
-ncu -u# 更新package.json 文件
-npm install# 更新yarn upgrade-interactive --latest更新全部包为最后版本 npm config set prefix
包目录地址yarn config set global-folder
包目录地址配置全局包地址 npm config set cache
缓存目录地址yarn config set cache-folder
缓存目录地址配置缓存地址 npm info vue version查看某包的版本 npm root -gyarn global dir查看全局包地址 yarn cache dir查看全局缓存地址 npm install [package] -gyarn global add [package]全局安装依赖 npm uninstall -g [package]yarn global remove [package]删除全局安装包 npm outdated [[<@scope>/]<pkg> ...]查看包过时 npm list -g --depth 0yarn global list查看全局安装的包有哪些 npm list --depth 0yarn list --depth 0查看项目下安装的包有哪些 npm inityarn init在项目中引导创建一个
package.json文件npm cache cleanyarn cache clean清除全局缓存
Node下常用的包的使用
安装yarn环境
1 | npm install -g yarn |
快速删除项目中的node_modules目录
全局安装rimraf模块
1
npm install rimraf -g
- 使用命令来删除目录
1
rimraf node_modules
Hexo的相关命令
全局安装 Hexo
1
npm install -g hexo-cli
创建文章
1
2
3hexo new [layout] <title>
Hexo 有三种默认布局:post、page 和 draft。在创建这三种不同类型的文件时,它们将会被保存到不同的路径;而您自定义的其他布局和 post 相同,都将储存到 source/_posts 文件夹。创建标签目录协助Front-matter使用
1
hexo new page tags
创建分类目录协助Front-matter使用
1
hexo new page categories