Gatsby: Unable to install sharp while running yarn

Created on 25 Mar 2020  路  8Comments  路  Source: gatsbyjs/gatsby

This is the setup of gatsby that I'm working with:
```System:
OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 80.0.3987.149
Firefox: 74.0
Safari: 13.1
npmPackages:
gatsby: ^2.20.6 => 2.20.6
gatsby-image: ^2.3.1 => 2.3.1
gatsby-plugin-catch-links: ^2.2.1 => 2.2.1
gatsby-plugin-google-analytics: ^2.2.2 => 2.2.2
gatsby-plugin-manifest: ^2.3.2 => 2.3.2
gatsby-plugin-offline: ^3.1.1 => 3.1.1
gatsby-plugin-postcss: ^2.2.0 => 2.2.0
gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0
gatsby-plugin-s3: ^0.3.2 => 0.3.2
gatsby-plugin-sharp: ^2.5.3 => 2.5.3
gatsby-plugin-sitemap: ^2.3.1 => 2.3.1
gatsby-plugin-styled-components: ^3.2.1 => 3.2.1
gatsby-plugin-typescript: ^2.3.1 => 2.3.1
gatsby-plugin-zopfli: ^1.3.2 => 1.3.2
gatsby-source-filesystem: ^2.2.1 => 2.2.1
gatsby-source-graphql: ^2.3.0 => 2.3.0
gatsby-transformer-sharp: ^2.4.2 => 2.4.2

This is the error that comes up when I run yarn (there's more to the error log that hasn't been included here):
```../src/common.cc:23:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/Personal/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/Users/Personal/.nvm/versions/node/v10.16.0/bin/node" "/Users/Personal/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Personal/Desktop/calisthenics-skills/node_modules/sharp

I've already tried the following:

  • Uninstalling and reinstalling expo-cli
  • Using different version of node (10.16.0 and 12.14.1)
  • Adding resolutions(minipass v2.7.0) for the sharp dependencies in the package.json file
  • Clearing yarn cache and running yarn after that
  • Deleting node_modules and yarn.lock and running yarn after that.
bug

Most helpful comment

I tried installing vips manually using brew but that did not seem to help and we stopped trying that after realizing @andrico1234 does not have vips installed

I was actually going to suggest uninstalling it if it was installed already 馃檪. It's been known to cause problems if there's a version installed already that sharp isn't expecting.

Can you see if ~/.npm/_libvips exists? That is the place sharp expects libvips to be cached

Yes ~/.npm/_libvips was present. I deleted it and ran yarn and it completed successfully. Thanks a lot for the solution

All 8 comments

i'd like to add that @suhaga15 and I are working on the same repo and I don't have any issues.

here's my output from gatsby info

System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Shell: 5.3 - /bin/zsh Binaries: Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm Languages: Python: 2.7.10 - /usr/bin/python Browsers: Chrome: 80.0.3987.149 Safari: 13.0 npmPackages: gatsby: ^2.20.6 => 2.20.6 gatsby-image: ^2.3.1 => 2.3.1 gatsby-plugin-catch-links: ^2.2.1 => 2.2.1 gatsby-plugin-google-analytics: ^2.2.2 => 2.2.2 gatsby-plugin-manifest: ^2.3.2 => 2.3.2 gatsby-plugin-offline: ^3.1.1 => 3.1.1 gatsby-plugin-postcss: ^2.2.0 => 2.2.0 gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0 gatsby-plugin-s3: ^0.3.2 => 0.3.2 gatsby-plugin-sharp: ^2.5.3 => 2.5.3 gatsby-plugin-sitemap: ^2.3.1 => 2.3.1 gatsby-plugin-styled-components: ^3.2.1 => 3.2.1 gatsby-plugin-typescript: ^2.3.1 => 2.3.1 gatsby-plugin-zopfli: ^1.3.2 => 1.3.2 gatsby-source-filesystem: ^2.2.1 => 2.2.1 gatsby-source-graphql: ^2.3.0 => 2.3.0 gatsby-transformer-sharp: ^2.4.2 => 2.4.2

@suhaga15 can you see if you have libvips (I believe on MacOS it's just called vips) installed on your system already? IIRC, sharp will download libvips if it is not already installed, but if it is, then it will use that one instead. Perhaps there is a version conflict

Just for extra context, I'm having no issue with installation, and i also don't have vips installed

@suhaga15 can you see if you have libvips (I believe on MacOS it's just called vips) installed on your system already? IIRC, sharp will download libvips if it is not already installed, but if it is, then it will use that one instead. Perhaps there is a version conflict

I tried installing vips manually using brew but that did not seem to help and we stopped trying that after realizing @andrico1234 does not have vips installed

I tried installing vips manually using brew but that did not seem to help and we stopped trying that after realizing @andrico1234 does not have vips installed

I was actually going to suggest uninstalling it if it was installed already 馃檪. It's been known to cause problems if there's a version installed already that sharp isn't expecting.

Can you see if ~/.npm/_libvips exists? That is the place sharp expects libvips to be cached

I tried installing vips manually using brew but that did not seem to help and we stopped trying that after realizing @andrico1234 does not have vips installed

I was actually going to suggest uninstalling it if it was installed already 馃檪. It's been known to cause problems if there's a version installed already that sharp isn't expecting.

Can you see if ~/.npm/_libvips exists? That is the place sharp expects libvips to be cached

Yes ~/.npm/_libvips was present. I deleted it and ran yarn and it completed successfully. Thanks a lot for the solution

I tried installing vips manually using brew but that did not seem to help and we stopped trying that after realizing @andrico1234 does not have vips installed

I was actually going to suggest uninstalling it if it was installed already 馃檪. It's been known to cause problems if there's a version installed already that sharp isn't expecting.

Can you see if ~/.npm/_libvips exists? That is the place sharp expects libvips to be cached

My bad, I jumped the gun a little bit!

Thanks so much for helping us!

You鈥檙e fine, @andrico1234. I鈥檓 just glad it鈥檚 working again 馃檪

Was this page helpful?
0 / 5 - 0 ratings