#Error installing sharp on convex

8 messages · Page 1 of 1 (latest)

somber compass
#

✖ Error fetching POST https://sensible-retriever-874.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze compress.js: Could not load the "sharp" module using the linux-arm64 runtime
Possible solutions:

sharp

High performance Node.js image processing. The fastest module to resize JPEG, PNG, WebP and TIFF images.

shrewd vergeBOT
#

Hi @somber compass. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error you're seeing when installing and using sharp with Convex is related to platform-specific native dependencies. Convex runs your code in a Linux ARM64 environment, so the sharp module must be installed with binaries compatible with that platform.

Key steps and considerations:

  1. Mark sharp as an external package:
    In your convex.json, ensure you have:

    {
      "node": {
        "externalPackages": ["sharp"]
      }
    }
    

    This tells Convex to install sharp on the server rather than bundling it, which is required for native modules like sharp External packages.

  2. Install platform-specific binaries:
    Since Convex runs on Linux ARM64, you need to ensure that the sharp package in your node_modules includes the correct binaries. The error message suggests running:

    npm install --os=linux --cpu=arm64 sharp
    

    or, if using optional dependencies:

    npm install --include=optional sharp
    

    This ensures the right binaries are available for Convex to use sharp won't work.

  3. Check your package manager:
    If you're using pnpm, there may be issues with how it handles optional or platform-specific dependencies. Some users have reported success by downgrading sharp to version 0.33.5 or by switching to npm for installing sharp sharp won't work.

  4. Consult sharp's installation docs:
    For more details on cross-platform installation, refer to sharp's official documentation.

#

Summary:

  • Mark sharp as an external package in convex.json.
  • Install sharp with Linux ARM64 binaries locally before pushing to Convex.
  • Consider using npm instead of pnpm if you encounter issues.
  • If problems persist, try downgrading to [email protected].

If you follow these steps and still encounter issues, please provide more details about your local environment and package manager for further troubleshooting.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@somber compass Kapa.ai is still learning and improving, please let me know how I did by reacting below.

somber compass
#

@shrewd verge Whats the pnpm command for npm install --os=linux --cpu=arm64 sharp?

shrewd vergeBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

I'm sorry, but the knowledge sources do not contain information about the equivalent pnpm command for npm install --os=linux --cpu=arm64 sharp. The documentation and support threads reference using npm for platform-specific installs, but do not mention how to achieve this with pnpm or if it is supported in the same way sharp won't work.

If you need to ensure platform-specific binaries with pnpm, you may need to consult the pnpm documentation or consider using npm for this step as suggested in the support threads.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: