gatsby: gatsby-plugin-sharp dependency problem?

  • Gatsby version: 1.7.2
  • Node.js version: 8.2.1
  • OS version: 10.12.16

I’ve ran into a problem after doing a clean install of this project. npm run dev failed with:

⠂ source and transform .../www/node_modules/bluebird/js/release/async.js:61
        fn = function () { throw arg; };
                           ^

Error: Cannot find module '../build/Release/sharp.node'

Looked like a dependency was missing. (I’m not sure why sharp didn’t install initially, given it is listed as a dependency of gatsby-plugin-sharp.) Either way, I manually installed it (npm i --save sharp) and re-ran npm run dev. This time it failed with:

⠂ source and transform .../www/node_modules/bluebird/js/release/async.js:61
        fn = function () { throw arg; };
                           ^

Error: .../www/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: @rpath/libvips-cpp.42.dylib
  Referenced from: .../www/node_modules/sharp/build/Release/sharp.node
  Reason: Incompatible library version: sharp.node requires version 50.0.0 or later, but libvips-cpp.42.dylib provides version 49.0.0

I’m not familiar with either of these dependencies- but I looked at the gatsby-plugin-sharp package.json file and saw it was depending on sharp ^0.17.3. My locally installed sharp was 0.18.12. This should be compatible but I decided to downgrade to 0.17.3 anyway and after doing so- the errors above went away.

Edit 1: It looks like any of the 0.18.* versions fail with a node-gyp error. Perhaps this failure causes the install to fail silently for some reason, which may be why sharp is missing after a fresh install. Maybe you want to remove the “^” from your version specifier?

Unfortunately npm run dev now seems to consume a lot of memory and hang after the following:

$ npm run dev

> react-website@0.0.1 dev /Users/bvaughn/Documents/git/react/www
> gatsby develop

success open and validate gatsby-config.js — 0.006 s
success copy gatsby files — 0.023 s
⠁ source and transform nodesWarning: No slug found for "README.md". Falling back to default "/README.html".
Warning: No slug found for "index.md". Falling back to default "/index.html".
success source and transform nodes — 1.433 s
success building schema — 0.441 s
success createLayouts — 0.021 s
success createPages — 0.430 s
success createPagesStatefully — 0.027 s
success extract queries from components — 0.192 s
success run graphql queries — 9.198 s
success write out page data — 0.017 s
success update schema — 62.771 s

bootstrap finished, time since started: 76.526 s

### Hung here for at least a couple of minutes.
### Terminal is unresponsive (even to Ctrl+C).

Next I tried uninstalling gatsby-transformer-sharp and gatsby-plugin-sharp and removing them from my gatsby-config. After doing this, npm run dev worked (in that it quickly spun up an HTTP server, although the remark plugin logged an error about the missing sharp plugin).

Then I tried re-adding gatsby-transformer-sharp (npm i --save gatsby-transformer-sharp) and I was still able to start the dev-server.

Lastly I tried re-adding gatsby-plugin-sharp (npm i --save gatsby-plugin-sharp) and the dev server now hangs instead of starting up.

Any chance you have an idea what might be going on? Any debug/log output I could provide that might shed some light?

Edit 2: For what it’s worth, I tried stepping Node down from 8.2.1 to 7.9.0 (another version I had installed) and re-npm-installing. (It seemed worth trying because this was the version of Node I was using a few weeks ago, when I first setup the Gatbsy site.) And sure enough, the server no longer hung after that- although things still look funky. I will keep investigating this and update the issue with my findings.

Edit 3: I’m losing my mind 😅 I did another clean install and now the dev server started up okay. Something seems to be going on with my machine, given the indeterminate behavior here, so I’m going to close this issue. I may still update it with my findings if I’m able to get to the bottom of this is a satisfactory manor.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 53 (37 by maintainers)

Commits related to this issue

Most upvoted comments

Deploy to Netlify still not work…

5:37:56 PM: success write out redirect data — 0.021
5:37:56 PM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZNK4vips6VImage7pngsaveEPKcPNS_7VOptionE
5:37:56 PM: npm
5:37:56 PM:  ERR! file sh

@bvaughn not sure if it helps, but I ran into issues with yarn after upgrading to node 8 and npm 5.

It seems that node-gyp was bundled with node 7 but not with node 8.

Doing npm install -g node-gyp resolved the issues for me.

Here’s the yarn issue: https://github.com/yarnpkg/yarn/issues/3728

I’m also running into the same issue when deploying to netlify.

System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.0.0 - /usr/local/bin/node
    Yarn: 1.6.0 - ~/.yarn/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: 64.0
    Safari: 12.0.2
  npmPackages:
    gatsby: next => 2.0.0-rc.28
    gatsby-image: next => 2.0.0-rc.4
    gatsby-plugin-canonical-urls: next => 2.0.0-rc.2
    gatsby-plugin-feed: next => 2.0.0-rc.2
    gatsby-plugin-google-analytics: next => 2.0.0-rc.2
    gatsby-plugin-manifest: next => 2.0.2-rc.1
    gatsby-plugin-netlify: next => 2.0.0-rc.6
    gatsby-plugin-nprogress: next => 2.0.0-rc.1
    gatsby-plugin-offline: next => 2.0.0-rc.9
    gatsby-plugin-react-helmet: next => 3.0.0-rc.1
    gatsby-plugin-sitemap: next => 2.0.0-rc.2
    gatsby-plugin-styled-components: next => 3.0.0-rc.5
    gatsby-plugin-svgr: next => 2.0.0-alpha
    gatsby-plugin-typography: next => 2.2.0-rc.3
    gatsby-remark-external-links: 0.0.4 => 0.0.4
    gatsby-remark-prismjs: next => 3.0.0-rc.2
    gatsby-source-contentful: next => 2.0.1-rc.9
    gatsby-source-filesystem: next => 2.0.1-rc.6
    gatsby-transformer-remark: next => 2.1.1-rc.5
    gatsby-transformer-sharp: next => 2.1.1-rc.3
  npmGlobalPackages:
    gatsby-cli: 2.4.5

UPDATE: I just updated the gatsby-plugin-manifest- to 2.0.13 and it works

this isn’t working. can some mention the specific package version of gatsby’s which worked.

Narrowed it down further to gatsby@1.7.0 (so likely somewhere in here). I’ll file a new issue about this since this one has gotten pretty noisy. 😄

Fixed by updating gatsby-plugin-manifest:

..
 "gatsby-plugin-manifest": "^2.2.9",
...

Any update here? This is a headache… Why was this closed? What is the solution?

Looks like this errors still occurs in the latest version of gatsby/gatsby-plugin-sharp:

  System:
    OS: macOS 10.14
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 11.3.0 - /usr/local/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: 64.0
    Safari: 12.0
  npmPackages:
    gatsby: 2.0.63 => 2.0.63
    gatsby-image: 2.0.22 => 2.0.22
    gatsby-plugin-favicon: 3.1.4 => 3.1.4
    gatsby-plugin-flow: 1.0.2 => 1.0.2
    gatsby-plugin-force-trailing-slashes: 1.0.4 => 1.0.4
    gatsby-plugin-jsxstyle: 0.0.4 => 0.0.4
    gatsby-plugin-manifest: 2.0.11 => 2.0.11
    gatsby-plugin-offline: 2.0.18 => 2.0.18
    gatsby-plugin-react-helmet: 3.0.4 => 3.0.4
    gatsby-plugin-sharp: 2.0.14 => 2.0.14
    gatsby-source-filesystem: 2.0.12 => 2.0.12
    gatsby-source-graphql: 2.0.7 => 2.0.7
    gatsby-transformer-json: 2.1.6 => 2.1.6
    gatsby-transformer-sharp: 2.1.9 => 2.1.9
  npmGlobalPackages:
    gatsby-cli: 2.4.6
    gatsby: 1.9.277

So on the hanging issue. I have seen that. Haven’t yet tried to debug it. From what I’ve found is if you kill the process and then restart it it starts quickly the second time.

for me this problem caused by changing node version globally.

rm -rf node_modules, then

npm i

helped.

I have same problem …

gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@10.16.1 | darwin | x64
gyp info find Python using Python version 2.7.10 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/macbook/.nvm/versions/node/v10.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   '/Users/macbook/Desktop/gatsby-blog/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/macbook/.nvm/versions/node/v10.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/macbook/Library/Caches/node-gyp/10.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=/Users/macbook/Library/Caches/node-gyp/10.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/macbook/.nvm/versions/node/v10.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/macbook/Library/Caches/node-gyp/10.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/macbook/Desktop/gatsby-blog/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' ]
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
In file included from ../src/common.cc:20:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/mutex:191:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__mutex_base:17:
/Library/Developer/CommandLineTools/usr/include/c++/v1/__threading_support:27:11: fatal error: 'pthread.h' file not found
# include <pthread.h>
          ^~~~~~~~~~~
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/macbook/.nvm/versions/node/v10.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196: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 18.7.0
gyp ERR! command "/Users/macbook/.nvm/versions/node/v10.16.1/bin/node" "/Users/macbook/.nvm/versions/node/v10.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/macbook/Desktop/gatsby-blog/node_modules/sharp

Read the entire thread, couldn’t get anything. This problem has started to show again with netlify and travis CI builds.

This ended up being caused by a more recent change than I suspected.

I stepped back a couple of weeks ago and everything seemed okay. Then I stepped forward about a day at a time. After checking out each revision, I ran: rm -rf ./.cache && rm -rf ./.node_modules && yarn install && yarn dev.

Turns out that things went bad with this recent commit: 6a55b33. The commit before it (b6fb888) works fine, assuming I first install node-gyp as a global (which is kind of clowny but that’s a separate issue).

The reason I saw the same hanging behavior toward the end of my initial issue was b’c I also ran yarn upgrade-interactive locally in an attempt to see if my original issue had already been fixed.

So one of the bumped dependencies seems to have caused this new permanently-hanging behavior. I’ll try to step through individual plugins next.

I was having this problem regarding gatsby-plugin-sharp and the problem got resolved by upgrading my dependencies. I hope it helps.

Just had this issue happen to me. Interesting enough I was working in another directory with an older version of gatsby blog starter but I want to start fresh. So, I downloaded a fresh copy and ran into the error above. I was forced to downgrade my node version. Current stable node version is: 12.0.0. This version creates the head ache seen above. node v11.14.0 worked for me and it worked perfectly. Didn’t have to add dependancies separately it just worked. Hope this helps someone 😃

I’m having an error in the netlify build too, Sharp seems involved.

9:25:21 PM: Executing user command: gatsby build 9:25:24 PM: success open and validate gatsby-configs — 0.179 s 9:25:25 PM: success load plugins — 0.339 s 9:25:25 PM: error Plugin gatsby-transformer-sharp returned an error 9:25:25 PM: 9:25:25 PM: Error: Could not locate the bindings file. Tried: 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/build/s harp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/build/D ebug/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/build/R elease/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/out/Deb ug/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/Debug/s harp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/out/Rel ease/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/Release /sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/build/d efault/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/compile d/8.15.0/linux/x64/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/addon-b uild/release/install-root/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/addon-b uild/debug/install-root/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/addon-b uild/default/install-root/sharp.node 9:25:25 PM: → /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp/lib/bin ding/node-v57-linux-x64/sharp.node 9:25:25 PM:
9:25:25 PM: - bindings.js:124 bindings 9:25:25 PM: [repo]/[bindings]/bindings.js:124:9 9:25:25 PM:
9:25:25 PM: - constructor.js:10 Object.<anonymous> 9:25:25 PM: [repo]/[gatsby-plugin-sharp]/[sharp]/lib/constructor.js:10:34 9:25:25 PM:
9:25:25 PM: - v8-compile-cache.js:178 Module._compile 9:25:26 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 1 9:25:25 PM: [repo]/[v8-compile-cache]/v8-compile-cache.js:178:30 9:25:25 PM:
9:25:25 PM: - v8-compile-cache.js:159 require 9:25:25 PM: [repo]/[v8-compile-cache]/v8-compile-cache.js:159:20 9:25:25 PM:
9:25:26 PM: Shutting down logging, 25 messages pending

@devdigital It should be fairly soon, see #4365

FWIW (might be unrelated) I also had a project using Yarn 0.27.5 in netlify.toml. Last week I decided to bump that to the latest stable Yarn—which I think was 1.3.0 at the time—and ran into build problems with Netlify after that. Then I stumbled upon #3570 and according to the information there gave Yarn 1.4.0 a try, but still had issues. I followed 3570#issuecomment-363591653 by @lourd to https://github.com/yarnpkg/yarn/issues/5152#issuecomment-363608999 and edited netlify.toml accordingly, adding --no-ignore-optional:

[build]
  command = "yarn run build"
  publish = "public"

[build.environment]
  NODE_VERSION = "9.5.0"
  YARN_VERSION = "1.4.0"
  YARN_FLAGS = "--no-ignore-optional"

After that things built fine again on Netlify without having to manually purge the cache.

Oh my goodness, that would be a nice improvement

Of course! I didn’t mean to sound complainy. (Hopefully I didn’t!) 😄 Was just thinking out loud.

Even if it did resolve the cache issue, it’s a pretty unsatisfying work-around. What if this happens on CI? or for other contributors?

For shizzle. This didn’t used to happen so it’s some sort of timing whatever thing. It should be pretty easy to debug so let’s get it fixed soon. It doesn’t seem to show up except on larger sites so I haven’t worried about it as much given other tasks at hand.