gatsby: "The dependency "sharp" does not seem to have been built or installed correctly." (possible Node 11 issue?)
Description
on a brand new gatsby project, i can’t run it right without deleting node_modules and reinstalling. it complains about node version, and i happen to run node 11 - do you think that is the problem here?
Steps to reproduce
gatsby new myappyarn start
Expected result
it runs a gatsby instance
Actual result
The dependency "sharp" does not seem to have been built or installed correctly.
- Try to reinstall packages and look for errors during installation
- Consult "sharp" installation page at http://sharp.pixelplumbing.com/en/stable/install/
If neither of the above work, please open an issue in https://github.com/gatsbyjs/gatsby/issues
Error: The module '/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:736:18)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at bindings (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/sharp/lib/constructor.js:10:34)
at Module._compile (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/Users/swyx/Netlify/NetlifyDevGatsbyThemeFaunaDemo/node_modules/sharp/lib/index.js:3:15)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.0.0 - /usr/local/bin/node
Yarn: 1.12.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 73.0.3683.86
Safari: 12.1
npmPackages:
gatsby: ^2.3.14 => 2.3.14
gatsby-theme-elevator-pitch: ^0.0.36 => 0.0.36
npmGlobalPackages:
gatsby-cli: 2.5.4
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 17 (15 by maintainers)
@sw-yx this seems like a good thing that it’s erroring out?
It’s hard to pin down what exactly happened here–did you change terminals? This error should only be thrown if the version of Node.js used in local project folder changed between install time (e.g.
gatsby newwhich runsyarn) and run time (e.g.cd project && yarn start).The error should be able to be remediated with:
but would still appreciate any more info you can provide re: how it got to that state. Not a great user experience to start with project broken–sorry about that!
i did not need to get there - i uninstalled node like you said and now it works!
its worth noting that VSCode seesm to have a bunch of options that also override node versions for no particular reason: https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm none of the solutions here worked at all. but deleting the node v11.0 worked. i should just go all-in on
nvm. i forget, sometimes.thank you everyone!!!
Not even a little bit! Happy to help.
Re: the underlying question. Is there an .nvmrc in the project?
Otherwise I maybe know what’s happening. I don’t think VSCode knows about nvm, so it will use the system path (the /usr/local/bin/node executable).
Does running
nvm alias default 11(or 10!) resolve the issue?npm rebuild sharpornpm rebuildshould work in most cases when your environemnt has changed.Sounds like you got a binary downloaded that’s not compatible with your version of node. Which is odd since it seems node 11 is supported now as a pre-built binary: https://sharp.dimens.io/en/stable/install/
Here’s a list of
NODE_MODULE_VERSIONs and what versions of Node they’re related to. You’ll notice that it says version 10 of Node for the module version 64.So unless other macOS users are also getting this problem with Node 11 and sharp pulling pre-built binaries for Node 10, something is wrong with your environment that’s retrieving the wrong binaries… Perhaps you have traces of Node 10 somewhere, either in the filesystem or environment variables?
Using Node 10 should resolve the issue in the meantime. Oh, if you had recently upgraded, it’s also possible that yarn might be pulling from a cached result maybe?
Just because an install with yarn seems to have worked fine without errors, doesn’t mean the install actually completed properly. If you install with NPM you’ll get an error when the binaries fail during install tests, but with yarn they’re silent errors, you need to use the verbose flag to catch them in terminal output unfortunately.
I doubt you’re the only one 😃 I’m at a conference this week–but maybe we set something up for next week?
correct, my issue is local dev related, not Travis
I was getting a somewhat similar issue, on my Travis CI build of Gatsby. In that I was getting the same error report about
sharp:I mention it here because that let me to #10677, where early throwing was added if
sharpwas not properly bound for an environment. So perhaps this issue would have existed previously for your environment, and is just being thrown now.For those interested, in my case, it was the
yarnversion that needed changing. Travis uses yarn1.3.2, which is why it wasn’t failing for me locally. Upgrading to the latest yarn for Travis (v1.15.2) resolved my CI error above (looks like that’s not at all the case for this issue)