Skip to content

Auto-detect WASM fallback for unsupported platforms (Termux/Android) #4563

Description

@kore4lyf

Problem

Sharp v0.35.2 fails to load on Termux (Android ARM64):

Error: Could not load the "sharp" module using the android-arm64 runtime

No prebuilt binaries exist for android-arm64v8.

Workaround (verified working)

npm install @img/sharp-wasm32

Proposed Solution

Auto-detect unsupported platforms and fall back to WASM:

if (loadError && !process.env.SHARP_IGNORE_WASM_FALLBACK) {
  try {
    module.exports = require('@img/sharp-wasm32');
    return;
  } catch (_wasmError) {}
}

Benefits

  • Zero-config for unsupported platforms
  • WASM is slower but functional
  • Opt-out via SHARP_IGNORE_WASM_FALLBACK=1

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions