gatsby: Unable to install gatsby-plugin-sharp

Description

I’m unable to install gatsby-plugin-sharp in Ubuntu 18.04. I’ve been working on a project that has been using gatsby-plugin-sharp as a dependency for weeks with no problem, until this morning.

Here’s a snippet of my package.json:

{
  "dependencies": {
    "gatsby-plugin-sharp": "^2.2.20",
    "gatsby-transformer-sharp":` "^2.2.13"
  }
}

Steps to reproduce

gatsby new gatsby-starter-hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
cd gatsby-starter-hello-world
npm install --save gatsby-plugin-sharp

Expected result

Should be able to install with no errors.

Actual result

yarn add v1.17.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "gatsby > eslint-config-react-app@4.0.1" has incorrect peer dependency "eslint-plugin-flowtype@2.x".
warning "gatsby > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
[-/7] ⠁ waiting...
[7/7] ⠁ sharp
[-/7] ⠁ waiting...
[-/7] ⠁ waiting...
error /home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: /home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp
Output:
info sharp Using cached /home/sean/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz
prebuild-install WARN install libvips-cpp.so.42: cannot open shared object file: No such file or directory
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.16.1 | linux | x64
gyp info spawn /usr/bin/python2.7
gyp info spawn args [ '/home/sean/.nvm/versions/node/v8.16.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/sean/.nvm/versions/node/v8.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/sean/.node-gyp/8.16.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/sean/.node-gyp/8.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/home/sean/.nvm/versions/node/v8.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/sean/.node-gyp/8.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:25:10: fatal error: vips/vips8: No such file or directory
 #include <vips/vips8>
          ^~~~~~~~~~~~
compilation terminated.
sharp.target.mk:127: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/sean/.nvm/versions/node/v8.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-62-generic
gyp ERR! command "/home/sean/.nvm/versions/node/v8.16.1/bin/node" "/home/sean/.nvm/versions/node/v8.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sean/Documents/gatsby-starter-hello-world/node_modules/sharp
gyp ERR! node -v v8.16.1

Environment

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 8.16.1 - ~/.nvm/versions/node/v8.16.1/bin/node
    Yarn: 1.17.3 - /usr/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.16.1/bin/npm
  Languages:
    Python: 3.7.3 - /home/sean/anaconda3/bin/python
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 69.0
  npmPackages:
    gatsby: ^2.13.73 => 2.15.21
    gatsby-background-image: ^0.8.9 => 0.8.12
    gatsby-image: ^2.2.14 => 2.2.20
    gatsby-plugin-catch-links: ^2.1.5 => 2.1.10
    gatsby-plugin-netlify: ^2.1.15 => 2.1.15
    gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0
    gatsby-plugin-netlify-cms: ^4.1.13 => 4.1.18
    gatsby-plugin-react-helmet: ^3.1.5 => 3.1.8
    gatsby-plugin-sass: ^2.1.12 => 2.1.15
    gatsby-plugin-sitemap: ^2.2.9 => 2.2.14
    gatsby-source-filesystem: ^2.1.16 => 2.1.26
    gatsby-transformer-remark: ^2.6.19 => 2.6.24

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 11
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@gpspake I’m having this issue as well, were you able to fix it?

**I fixed it after upgrading Gatsby and deleting node_modules and the lockfile.

@foxdoubt Are you putting

  "resolutions": {
    "minipass": "2.7.0"
  }

in your package.json? That’s the only way I’m able to get it to work right now.

I had same issue when having new project with gatsby. You can just make sure you remove node modules rm -rf node_modules/ inside your project, then sudo npm install --unsafe-perm instead of using npm install only.

I’m experiencing the same issue with Node 10, 11, and 12. Was working this morning for me, until I tried to reload my dependencies.

  System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Shell: 3.0.2 - /usr/local/bin/fish
  Binaries:
    Node: 11.15.0 - ~/.nvm/versions/node/v11.15.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.15.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/local/bin/python
  Browsers:
    Chrome: 76.0.3809.132
    Safari: 12.1.2

There is an issue open on the sharp repo

I also came from here: https://github.com/lovell/sharp/issues/1882

so for me i patched package.json vis:

  "resolutions": {
    "minipass": "^3.1.3",
    "sharp": "^0.29.0"
  },
  "dependencies": {
    "minipass": "2.7.0",
    "sharp": "^0.29.0",
    "gatsby-plugin-sharp": "latest",
    "gatsby-transformer-sharp": "latest",

now i get some other errors.

this finally decided me to redo my site in plain create-react-app, this fragility is too much

Quick fix: Use yarn for installation (instead of npm). Solved the problem for me.

I ran into the same issue:

  • gatsby develop would throw an error (Something went wrong installing the "sharp" modul)
  • I deleted node_modules and tried to reinstall. Same issue
  • I deleted package.lock and tried to reinstall. Same issue

Then I figured out that I set my package manager to yarn but was trying to run npm install. 🤦 You can check the package manager you chose in ~/.config/gatsby/config.json.

What fixed the issue for me then was:

  • Upgrade yarn
  • Delete yarn.lock
  • Run yarn install
  • Run yarn add gatsby-cli
  • Run gatsby develop

Hope that helps someone

@flashimxd Hmmmm…I can’t remember exactly. I’m usually using yarn, so I may have done: $ yarn upgrade gatsby You can read about it here: https://classic.yarnpkg.com/en/docs/cli/upgrade/

Another way I have done it is to change the version in the package.json and then run the install again. You may need to delete the node_modules first though.

I think I did the yarn upgrade…

@swkeever I installed another project with gatsby new <site-name>, confirmed that the install made it through the sharp installation part, and when I navigated back to my original site repo and npm installed again, the problem had been resolved. I guess it’s possible that the fresh install with gatsby new did something.

but no, not using "resolutions" in package.json