gatsby: Something went wrong installing the "sharp" module
Description
gatsby develop
fails on existing site or even a new build.
Full error below:
Error in "/Users/hsnyc/Documents/Hosts/hsnyc/hsnyc_v4/hsnyc-gatsby/node_modules/gatsby-transformer-sharp/gatsby-node.js":
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'
- Run "npm rebuild --verbose sharp" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/install
- Search for this error at https://github.com/lovell/sharp/issues
Error: Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'
- Run "npm rebuild --verbose sharp" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/ install
- Search for this error at https://github.com/lovell/sharp/issues
- constructor.js:34 Object.<anonymous>
[hsnyc-gatsby]/[sharp]/lib/constructor.js:34:9
- v8-compile-cache.js:178 Module._compile
[hsnyc-gatsby]/[v8-compile-cache]/v8-compile-cache.js:178:30
- loader.js:789 Object.Module._extensions..js
internal/modules/cjs/loader.js:789:10
- loader.js:653 Module.load
internal/modules/cjs/loader.js:653:32
- loader.js:593 tryModuleLoad
internal/modules/cjs/loader.js:593:12
- loader.js:585 Function.Module._load
internal/modules/cjs/loader.js:585:3
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[hsnyc-gatsby]/[v8-compile-cache]/v8-compile-cache.js:159:20
- index.js:3 Object.<anonymous>
[hsnyc-gatsby]/[sharp]/lib/index.js:3:15
- v8-compile-cache.js:178 Module._compile
[hsnyc-gatsby]/[v8-compile-cache]/v8-compile-cache.js:178:30
- loader.js:789 Object.Module._extensions..js
internal/modules/cjs/loader.js:789:10
- loader.js:653 Module.load
internal/modules/cjs/loader.js:653:32
- loader.js:593 tryModuleLoad
internal/modules/cjs/loader.js:593:12
- loader.js:585 Function.Module._load
internal/modules/cjs/loader.js:585:3
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[hsnyc-gatsby]/[v8-compile-cache]/v8-compile-cache.js:159:20
not finished load plugins - 0.330s
Steps to reproduce
Had node 8 installed when I first noticed the error. Upgraded to 12, cleared npm cache npm cache clear
and gatsby cache gatsby clean
. Rebuild npm rebuild --verbose sharp
no errors.
Downgraded to Node 10 and repeated the above steps. Same error.
Expected result
To have the local server run.
Actual result
Sharp error
Environment
System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 10.18.0 - /usr/local/bin/node npm: 6.13.4 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 83.0.4103.61 Firefox: 57.0.4 Safari: 13.1 npmPackages: gatsby: ^2.21.37 => 2.21.37 gatsby-image: ^2.4.4 => 2.4.4 gatsby-plugin-manifest: ^2.4.5 => 2.4.5 gatsby-plugin-offline: ^3.2.3 => 3.2.3 gatsby-plugin-react-helmet: ^3.3.1 => 3.3.1 gatsby-plugin-sharp: ^2.6.4 => 2.6.4 gatsby-source-filesystem: ^2.3.4 => 2.3.4 gatsby-transformer-sharp: ^2.5.2 => 2.5.2 npmGlobalPackages: gatsby-cli: 2.12.36
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 22 (2 by maintainers)
Well after various attempts to resolve I finally found a solution.
Here is how I was able to get it to work (Using a MAC):
The aforementioned code did the trick for me.
npm rebuild --verbose sharp
Are you able to share your project so we can try to reproduce? Can you try running
npm ls sharp
? Also output ofnpm rebuild --verbose sharp
could be helpful.For my case:
Environment:
macOS M1 (AMD arch) node v15.5.0 Homebrew 3.0.1 npm 7.3.0
fix that worked for me:
1--------------------
Ref: https://sharp.pixelplumbing.com/install#apple-m1 2------------------ After installing vips, Delete both
yarn.lock/package-lock.json
andnode_modules
That might sound funny but today I installed web3 package and for some reason sharp started throwing errors again, I went really deep to fix the issue and tried almost all options that found ( install shaps globally,openxr…etc) and found 1 weird answer is to uninstall vips [here]
(https://www.gitmemory.com/issue/lovell/sharp/2729/851516872) and it worked, it looks that sharp team are building the package without using homebrew version 0.28.0 here (its a long thread so try to uninstall vips as first option). Actually as per my understanding: uninstall vips and resolve sharp with 0.28.0 version will work fine.
For me, the problem is about the node’s version. I use nvm and tested with three versions:
14.14.0 12.19.0 10.22.1
Only 10.22.1 works for me. I recommend using the nvm (Node Version Manager) to deal with this.
I have this problem on Windows. I use
yarn
for dependency management, but after installing all deps and runningyarn build
, I get an error:Simply deleting
node_modules
and reinstalling all the deps again fixed it.For me, @uranium93 solutions (step 1 only) worked for me:
brew install vips
Hi! If anyone is still having this issue: I tracked it down to forgetting to exclude my node_modules to upload on the gitignore. Therefore when I cloned to a new computer with a different OS it didn’t find the same packages cause they’re not the same for different OS. Simple solution? To me it was just erasing the node_modules directory and reinstalling them with a npm install.
I second the
brew install vips
fix for macThis should work for folks on M1 Mac
Install Rossette2 if you havent already:
Remove lock file and node_modules
Reinstall using
arch -x86_64
Run your dev environment using
arch -x86_64
Setup alias so you don’t have to specify the arch everytime:
And then simply
yarn dev
Fifty billion years later:
🎉
For me (MacBook Pro M1) I had to downgrade to Node v14 for it to work. It was not working using Node v16. I’m using Sharp
0.31.3
With nvm:
nvm use 14
rm -rf node_modules
npm i
@Mtea994 My mistake. I chimed in before I was adequately caffeinated. I was running into a very similar error but not using Gatsby. I was so excited that I jumped to share. Sorry!
gatsby version v^5 requires node v^18 to work how did you make it work ?
I ran into this problem after updating plugins out of step with each other, and there were multiple sharp installs in my package. I ran yarn why sharp and made sure to upgrade all the results to their latest and the problem went away.