环境要求
在安装和部署本网站前,请确保你的开发环境满足以下要求:
- 操作系统:Windows、macOS 或 Linux
- Node.js:建议 16.x 或 18.x(推荐 LTS 版本)
- npm:建议 8.x 及以上(Node.js 自带)
- Git:用于克隆代码仓库
Node.js 安装指导
方式一:官网下载
- 访问 Node.js 官网,下载对应操作系统的安装包并安装。
- 安装完成后,命令行输入
node -v
和npm -v
检查版本。
方式二:使用 nvm(推荐,便于多版本管理)
- nvm for Windows
- nvm for macOS/Linux
- 安装 nvm 后,运行:
nvm install 18
nvm use 18
node -v
npm -v
npm/yarn 国内镜像源配置方法
临时使用国内镜像
每次安装依赖时加上 --registry
参数:
npm install --registry=https://registry.npmmirror.com
全局设置 npm 镜像源
以后所有 npm install 都会自动使用国内镜像:
npm config set registry https://registry.npmmirror.com
检查当前 npm 镜像源:
npm config get registry
输出应为:
https://registry.npmmirror.com/
恢复为官方源
npm config set registry https://registry.npmjs.org
yarn 镜像源配置(如有用 yarn)
yarn config set registry https://registry.npmmirror.com
提示
更多国内镜像源和包管理器配置方法,详见 我收录的镜像库。
检查版本
可以通过以下命令检查 Node.js 和 npm 版本:
node -v
npm -v
git --version
下一步:克隆代码仓库