Skip to content

Installation of "sharp" npm package fails with NodeJS v22. #39514

@Taras-Dyda

Description

@Taras-Dyda

Preliminary Checks

Description

We use the "gatsby-plugin-sharp" and "gatsby-transformer-sharp" npm packages in our project. The issue is that, during the production build, when yarn installs modules, it sometimes throws errors while installing the sharp package. This issue occurs rarely. When the installation process fails, we encounter one of the following errors:

  1. Timeout error:
Image
  1. fatal error: glib-object.h: No such file or directory
Image

This error started happening after upgrading Node.js from version 20 to version 22. These errors occur only during the production build when installing node modules (on Netlify in our case). I do not encounter this issue locally.

Reproduction Link

https://www.gatsbyjs.com/

Steps to Reproduce

  1. Install NodeJS v22
  2. Add gatsby-plugin-sharp and gatsby-transformer-sharp dependencies to your project
  3. Remove node_modules folder
  4. Install node modules (An error should appear at this step.)
  5. This error occurs rarely, so it might be difficult to reproduce it.

Expected Result

Installation of npm packages should complete successfully as part of the production build.

Actual Result

The installation of npm packages sometimes fails during the production build, with the errors described in the description section.

Environment

System:
    OS: macOS 15.7.4
    CPU: (12) arm64 Apple M3 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.22.0 - ~/.nvm/versions/node/v22.22.0/bin/node
    Yarn: 4.10.3 - ~/.nvm/versions/node/v22.22.0/bin/yarn
    npm: 10.9.4 - ~/.nvm/versions/node/v22.22.0/bin/npm
  Browsers:
    Safari: 18.6

Config Flags

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage neededIssue or pull request that need to be triaged and assigned to a reviewertype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions