0

I'm developing a project using Next.js 15.5.4 inside an Electron.js application, with the following stack:

  • React.js
  • Tailwind CSS
  • SQLite

On Windows 11, running npm run build (or next build) consistently fails with:

⨯ ENOENT: no such file or directory, scandir 'C:\Users\<username>\<project-folder>\node_modules\@img\sharp-darwin-arm64'

I have tried several approaches:

  • Deleting node_modules and package-lock.json
  • Cleaning the npm cache (npm cache clean --force)
  • Installing Sharp explicitly for Windows:
npm install sharp --ignore-scripts=false --platform=win32 --arch=x64
  • Setting images: { unoptimized: true } in next.config.js
  • Adding Sharp as a webpack external:
config.externals.push({ sharp: 'commonjs sharp' });
  • Removing .next and rebuilding

However, the error still occurs. It seems that Next.js attempts to scan the macOS Sharp binary (sharp-darwin-arm64) from @img, even though I'm on Windows 11 and never developed this project on a Mac.

My questions:

  1. Why does Next.js attempt to scan a Mac-specific Sharp binary on Windows in an Electron environment?
  2. Is there a way to fully ignore or bypass @img/sharp-darwin-arm64 on Windows?
  3. Are there known workarounds for Electron + Next.js projects where Sharp binaries are platform-specific?
1

1 Answer 1

0

Try rebuilding native modules with

@electron/rebuild

Another, more destructive approach is to nuke your node_modules along with any lock files and doing a reinstall with

npm install sharp --platform=win32 --arch=x64

...outlining the binary you desire with parameters shown above

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.