nuxt / nuxt/content

`ensurePackageInstalled` kills the dev server on pnpm >= 10 even though the install succeeded (ERR_PNPM_IGNORED_BUILDS)

Open Beginner friendly
#3,849 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.7k
Forks
746
Avg merge
1d 16h
Merged PRs (30d)
3

Description

Environment
  • Operating System: Darwin (macOS 26.6.2, arm64)
  • Node Version: v26.8.1
  • Nuxt Version: 4.5.2
  • Package Manager: pnpm@12.3.4
  • Module: @nuxt/content@3.16.0
Version

3.16.0

Reproduction
  1. Use pnpm >= 10 (build scripts are blocked by default).
  2. Start a Nuxt project with @nuxt/content and no better-sqlite3 in package.json.
  3. Run nuxt dev and answer Yes to the "Do you want to install better-sqlite3 package?" prompt.
Description

ensurePackageInstalled calls addDependency without guarding against a non-zero exit from the package manager (src/utils/dependencies.ts):

await addDependency(pkg, {
  cwd: tryUseNuxt()?.options.rootDir,
})

On pnpm >= 10, pnpm add better-sqlite3 succeeds at adding the dependency and then exits non-zero with ERR_PNPM_IGNORED_BUILDS, because pnpm refuses to run a package's build scripts until they are approved. nypm surfaces that exit code as a throw, and the whole dev server dies:

dependencies:
+ better-sqlite3 13.0.3

Error: ERR_PNPM_IGNORED_BUILDS

  × adding a new package
  ╰─▶ Ignored build scripts: better-sqlite3@13.0.3
  help: Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.

 ERROR  pnpm add better-sqlite3 failed.

    at executeCommand (node_modules/.pnpm/nypm@0.6.9/node_modules/nypm/dist/index.mjs:79:28)
    at async addDependency (node_modules/.pnpm/nypm@0.6.9/node_modules/nypm/dist/index.mjs:380:28)
    at async ensurePackageInstalled (@nuxt/content/dist/module.mjs:230:5)
    at async findBestSqliteAdapter (@nuxt/content/dist/module.mjs:414:3)
    at async getDatabase (@nuxt/content/dist/module.mjs:302:17)
    at async getLocalDatabase (@nuxt/content/dist/module.mjs:310:63)
    at async processCollectionItems (@nuxt/content/dist/module.mjs:3347:14)
    at async initNuxt (nuxt/dist/index.mjs:7811:2)

The install genuinely worked — my lockfile records better-sqlite3: specifier ^13.0.3, version 13.0.3 and package.json was updated. Simply re-running nuxt dev starts fine. The crash and stack trace are pure noise.

This is especially gratuitous on better-sqlite3 v13, which needs no build step at all. v13 dropped the install script entirely, sets "gypfile": false, and ships prebuilt binaries for all 8 platforms in prebuilds/. I confirmed the freshly installed, never-built copy works:

$ node -e "const D=require('better-sqlite3'); console.log(new D(':memory:').prepare('select sqlite_version() v').get())"
{ v: '3.53.4' }

So nuxt-content aborted the dev server over a build that (a) had already effectively succeeded and (b) was never needed in the first place.

Additional context

Related but distinct from #3329, which was about better-sqlite3 v11 genuinely failing to compile, and was closed as stale. This report is narrower: the install succeeds and the module works, yet nuxt-content still exits.

Separately, and not a nuxt-content bug: after pnpm approve-builds, pnpm ran node-gyp rebuild on better-sqlite3 13.0.3 despite it having no install script and declaring "gypfile": false. pnpm appears to trigger on the presence of binding.gyp in the tarball and ignore gypfile: false. That fails with node-gyp: command not found, but is harmless since the prebuilt binary is already in place. Noting it only because it appears in the same log and could confuse triage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/utils/dependencies.ts at ensurePackageInstalled and inspect how addDependency errors are handled. Reproduce the installation through nuxt dev with pnpm >= 10 and no better-sqlite3 dependency. Done means a successful dependency addition with ERR_PNPM_IGNORED_BUILDS does not terminate the dev server.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.