Ignored build scripts: sharp.
Run "pnpm approve-builds" to pick which dependencies should be allowed
to run scripts.
Why am I getting this error message in the Vercel build script? How can I fix this?
This error occurs because pnpm has a security feature that prevents packages from automatically running install/build scripts unless explicitly approved. In your case, the Sharp image processing library needs to run build scripts during installation to compile its native dependencies 1.
You have a few options to resolve this issue:
Run the suggested command in your local development environment:
pnpm approve-buildsThis will prompt you to select which packages should be allowed to run scripts. Select "sharp" from the list.
Add the following to your .npmrc file in your project root:
enable-pre-post-scripts=true
unsafe-perm=trueOr specifically allow just the Sharp package:
public-hoist-pattern[]=sharpYou can modify your build command in your Vercel project settings to include the approval:
pnpm config set enable-pre-post-scripts true && pnpm install && pnpm buildThis is a security feature in pnpm that helps prevent potentially malicious code from executing during package installation. Since Sharp needs to compile native code during installation, it requires these build scripts to run properly.
After implementing one of these solutions, your build should complete successfully with Sharp properly installed and functioning.