如何解决NuxtContent的better-sqlite3报错

2025-12-1910 mins readfrontendvue

错误现象

安装 nuxt-content 模块并选择 better-sqlite3 , 启动开发服务器会报错

powershell

loading...

错误分析

这是因为 better-sqlite3nodejs 原生模块, 需要编译安装

错误处理

  1. 确保安装了 Visual Studio 里的 C++桌面开发 套件
  2. devDependencies 中添加 better-sqlite3
  3. onlyBuiltDependencies 中添加 better-sqlite3
package.json

loading...

  1. 删除 node_modules
  2. 清除一下 pnpm 存储 pnpm store prune
  3. 现在应该可以正常运行了

--- 评论区施工中🚧 ---

CC BY-NC-SA 4.0