设置代理

  1. npm config set proxy=http://127.0.0.1:8087
  2. npm config set registry=http://registry.npmjs.org

关于https
经过上面设置使用了http开头的源,因此不需要设https_proxy了,否则还要增加一句:

  1. npm config set https-proxy http://server:port

代理用户名和密码

  1. npm config set proxy http://username:password@server:port
  2. npm confit set https-proxy http://username:password@server:port

取消代理

  1. npm config delete proxy
  2. npm config delete https-proxy

修改源

  1. #查看代理
  2. yarn config list
  3. #删除代理
  4. yarn config delete proxy
  5. npm config rm proxy
  6. npm config rm https-proxy
  7. #安装好后更换淘宝镜像
  8. yarn config set registry https://registry.npm.taobao.org

  1. # 安装nodejs、同时也会自动安装npm
  2. yum -y install nodejs
  3. # 下载nodejs的版本管理
  4. npm install -g n
  5. # nodejs更换稳定版本
  6. n stable
  7. # nodejs更换安装指定版本
  8. n v14.0.0
  9. # node的版本
  10. node -v
  11. npm install yarn
  12. yarn config set registry https://registry.npm.taobao.org
  13. npm config set registry=https://registry.npm.taobao.org

vuepress Node内存溢出

默认Node内存是低于2G的,当我们构建几百个markdown文档时肯定是内存不够的。
所以需要提高Node的内存,在这里我们使用8G,我这里569个markdown文档消耗了5.8G内存

1.安装插件

  1. yarn add increase-memory-limit
  2. yarn add cross-env

2.修改package.json的scripts字段

  1. "scripts": {
  2. "dev": "cross-env NODE_OPTIONS=\"--max_old_space_size=8196\" vuepress dev docs",
  3. "build": "cross-env NODE_OPTIONS=\"--max_old_space_size=8196\" vuepress build docs"
  4. },

3.正常运行,此时Node最大内存是8G

  1. yarn start

迁移vuepress项目

  1. # 进入到vuepress项目,删除插件目录
  2. rm -rf node_modules/
  3. #
  4. yum -y install nodejs
  5. npm install yarn
  6. yarn config set registry https://registry.npm.taobao.org
  7. npm config set registry=https://registry.npm.taobao.org
  8. npm install yarn --global
  9. yarn install
  10. yarn global add vuepress
  11. npm init vuepress-theme-hope

瓦雀