包管理工具

  1. #查看包管理工具设置
  2. yarn config list
  3. npm config list
  4. #全局安装过的包
  5. npm list -g
  6. npm list -g --depth 0
  7. #全局可升级的包
  8. npm -g outdated
  9. npx -p node@12(版本号,可以是大版本也可以是指定版本)
  10. #清除缓存
  11. npm cache verify
  12. npm cache clear --force
  13. yarn cache clean
  14. # 清除PowerShell历史
  15. alt+f7

npm 切换源

  1. #包管理工具原有数据源
  2. npm config set registry https://registry.npmjs.org
  3. yarn config set registry https://registry.yarnpkg.com
  4. #淘宝源
  5. npm config set registry https://registry.npmmirror.com
  6. yarn config set registry https://registry.npmmirror.com
  7. #个别包设置源
  8. npm config set electron_mirror https://npmmirror.com/mirrors/electron/
  9. npm config set sass_binary_site https://npmmirror.com/mirrors/node-sass/
  10. yarn config set electron_mirror https://npmmirror.com/mirrors/electron/
  11. yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass/

Node版本切换

node库下载链接:https://nodejs.org/download/release
nvm下载链接:https://github.com/coreybutler/nvm-windows/releases

  1. #需要管理员权限
  2. #查看已安装node版本
  3. nvm ls
  4. # 安装对应版本的node
  5. nvm install v版本号
  6. # 卸载对应版本的node
  7. nvm uninstall xxx
  8. # 选择使用版本
  9. nvm use xxx

安装 Homebrew

  1. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew操作

  1. // 要获取最新的包的列表
  2. brew outdated
  3. // 更新所有的包
  4. brew upgrade
  5. // 更新指定的包
  6. brew upgrade $FORMULA
  7. // 清理所有包的旧版本
  8. brew cleanup
  9. // 清理指定包的旧版本
  10. brew cleanup $FORMULA
  11. // 查看可清理的旧版本包,不执行实际操作
  12. brew cleanup -n
  13. // 查看已安装的包的依赖,树形显示
  14. brew deps --installed --tree
  15. // 显示安装了包数量,文件数量,和总占用空间
  16. brew info

安装软件npm

  1. brew install git
  2. brew install node
  3. brew install yarn
  4. npm i -g eslint

生成ssh

  1. ssh-keygen -t rsa -C "you9009@foxmail.com"

打开ssh

  1. open ~/.ssh

修改环境变量

  1. // 创建文件
  2. touch ~/.bash_profile
  3. // 打开文件
  4. open -t ~/.bash_profile
  5. // 运行文件,使配置生效:
  6. source ~/.bash_profile
  7. // 检查是否生效:
  8. echo $PATH

新建文件夹/文件

  1. mkdir name
  2. touch name