VitePress 安装教程
更新: 7/13/2025 字数: 0 字 时长: 0 分钟
VitePress 是一个由 Vite 和 Vue 驱动的静态站点生成器(SSG)。
它设计简洁、性能出色,非常适合用于构建技术文档、博客和个人网站。
前期工作
工具安装
更换
Node.js
镜像源bash# 查看源 npm config get registry # 更换阿里云源 npm config set registry https://registry.npmmirror.com/ # 换回默认源 npm config set registry https://registry.npmjs.org/
安装
pnpm
包管理器bash# 安装 pnpm npm install -g pnpm # 查看版本号 pnpm -v
创建目录
找一个你熟悉的地方新建一个空文件夹
安装
全新安装
安装依赖
- 使用 VS Code 打开这个空文件夹,在 VS Code 中使用快捷键
Crtl
+~
打开终端 - 然后我们在终端使用下面的命令安装 VitePress
bashpnpm add -D vitepress
- 使用 VS Code 打开这个空文件夹,在 VS Code 中使用快捷键
初始化向导
bashpnpm vitepress init
bashT Welcome to VitePress! | o Where should VitePress initialize the config? | ./docs | o Site title: | My Awesome Project | o Site description: | A VitePress Site | o Theme: | Default Theme | o Use TypeScript for config and theme files? | Yes | o Add VitePress npm scripts to package.json? | Yes | — Done! Now run npm run docs:dev and start writing.
现有安装
下载仓库
安装依赖
- 使用 VS Code 打开解压后的文件夹,在 VS Code 中使用快捷键
Crtl
+~
打开终端 - 然后在终端使用下面的命令安装依赖
bashpnpm install
- 使用 VS Code 打开解压后的文件夹,在 VS Code 中使用快捷键
启动
本地启动开发环境,来开发你的网站
bash
pnpm run docs:dev
生成了一个本地 5173
端口的链接,复制到浏览器打开进行预览
bash
C:\myWebsite\Vitepress>pnpm run docs:dev
> @ docs:dev C:\myWebsite\Vitepress
> vitepress dev docs
vitepress v1.6.3
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
按 Ctrl
+ C
即可退出开发模式