'Error: Something went wrong installing the "sharp" module / Something went wrong installing the "sharp" module

I have a Gatsby project using Gatsby version 3.14.3. I need to install gatsby-plugin-image so I can have optimised images in my project. I added necessary configuration in gatsby-config:

plugins: [
  `gatsby-plugin-image`,
  `gatsby-plugin-sharp`,
  `gatsby-transformer-sharp`,
],

and tried installing packages as well:

"gatsby-plugin-image": "1.14.1",
"gatsby-plugin-sharp": "3.14.3",
"gatsby-transformer-sharp": "3.14.0",

Note that I think these package versions are compatible with my current Gatsby version.

I get an error Error: Something went wrong installing the "sharp" module after running yarn run develop. I've tried multiple changes from other people's threads that had similar problem and couldn't make it work. I will look into updating my project to the latest Gatsby version, but it is a big project and I need to prioritise making the images work for now.

Terminal screenshot as reference: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source