环境配置

安装 node.js 以及配置 yarn 和 npm 。


开发环境

# 安装 node.js (提供 npm 安装包)
wget https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz
tar -xvf node-v16.15.1-linux-x64.tar.xz -O ~/Program/node
echo "export PATH=$PATH:/home/echoxu/Programe/node-v16.14.2-linux-x64/bin" >> ~/.bashrc
source ~/.bashrc
# 使用 npm 安装 yarn
npm install --global yarn

# 添加进环境变量
export PATH=$PATH:/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global/bin

# 查看是否安装成功
yarn --version

# 修改安装源
yarn config set registry 'https://registry.npm.taobao.org'

# 修改全局安装包存储路径
yarn config set global-folder "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global/yarn_global"

# 修改临时目录
yarn config set tmp "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global/tmp"

# 改变yarn bin位置
yarn config set prefix "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global/yarn_global"

# 设置 yarn 缓存路径
yarn config set cache-folder "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_cache/yarn_cache"

# 查看当前yarn的全局安装位置
yarn config dir

# 查看所有配置
yarn config list

# 当前配置文件
/home/echoxu/.yarnrc

# 修改 npm 安装包存储目录
npm config set prefix "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global"

# 修改 npm 缓存目录
npm config set cache "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_cache"

# 查看所有配置项
npm config ls -l

# 用户自定义配置文件
/home/echoxu/.npmrc

#查看安装源
npm config get registry

# 修改安装源
npm config set registry 'https://registry.npmmirror.com'

# 设置临时目录
npm config set tmp "/home/echoxu/Programe/node-v16.14.2-linux-x64/node_global/tmp"

FAQ

  • "https://registry.npm.taobao.org/create-vuepress: certificate has expired".
  • npm config list 查看得到用的是淘宝的镜像
  • 清空缓存:npm cache clean --force
  • 执行: npm config set registry https://registry.npmmirror.com
  • vuepress 2.0.0-rc.8 需要 Node.js 在 nodejs1.18 以上
上次更新:
贡献者: iEchoxu