DEV Community

Cover image for `pnpm dev` fails because of `sharp`: the warning that blocks everything
Amine Affif
Amine Affif

Posted on

`pnpm dev` fails because of `sharp`: the warning that blocks everything

I run pnpm dev and nothing starts. No error in my code. Just this:

[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: sharp@0.34.5
Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.
[ERROR] Command failed with exit code 1: pnpm install
Enter fullscreen mode Exit fullscreen mode

Before running the script, pnpm checks the state of the dependencies. That check was failing, so the server never started.

The cause. Recent versions of pnpm no longer run dependencies' install scripts without explicit approval. The allowBuilds setting, added in 10.26, is how you approve them. A package that isn't listed is considered unreviewed, and by default that produces an error. sharp, the image optimizer Next.js uses, has exactly such a script: it installs its native binary.

My pnpm-workspace.yaml held a placeholder that was never filled in:

allowBuilds:
  sharp: set this to true or false
Enter fullscreen mode Exit fullscreen mode

The fix:

allowBuilds:
  sharp: true
Enter fullscreen mode Exit fullscreen mode

Then pnpm install: the sharp script runs, and pnpm dev starts again.

You can also run pnpm approve-builds, which writes the same thing: true for an approved package, false for a refusal.

One setting to avoid: dangerouslyAllowAllBuilds. It allows every script, including those of future transitive dependencies. An install script runs with your privileges, so it's better to approve case by case.

Amine Affif, full-stack developer in Paris. amineaffif.com

Top comments (0)