I cloned a Gatsby project from my GitHub profile (https://github.com/kylemadkins/website) to a different computer and ran npm ci
and then npm run develop
and got this error:
Something went wrong installing the "sharp" module
Module did not self-register.
- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
There were no errors after running npm ci
, just after running npm run develop
. Note that it worked fine after upgrading to Node v10.16.3. So I'm not sure if this is expected with Node 9 or not鈥擨 know it's not an LTS version. If this is expected, I apologize
npm ci
to install from package-lock.json
npm run develop
Running on Chrome Version 76.0.3809.132 (Official Build) (64-bit) and macOS High Sierra 10.13.3
This might be expected with the Node version I was using, but I expected it to run gatsby develop
successfully after installing from package-lock.json
successfully
I got the error I pasted above
I ran gatsby info
after upgrading Node to v10 so the Node version and npm version are off here vs. when I ran into the issue
System:
OS: macOS High Sierra 10.13.3
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 77.0.3865.90
Firefox: 66.0.2
Safari: 11.0.3
npmPackages:
gatsby: ^2.15.29 => 2.15.29
gatsby-image: ^2.2.24 => 2.2.24
gatsby-plugin-manifest: ^2.2.20 => 2.2.20
gatsby-plugin-offline: ^3.0.11 => 3.0.11
gatsby-plugin-react-helmet: ^3.1.10 => 3.1.10
gatsby-plugin-sharp: ^2.2.28 => 2.2.28
gatsby-source-filesystem: ^2.1.29 => 2.1.29
gatsby-source-wordpress: ^3.1.39 => 3.1.39
gatsby-transformer-sharp: ^2.2.20 => 2.2.20
npmGlobalPackages:
gatsby-cli: 2.7.54
Hi @kylemadkins ,
When gatsby-plugin-sharp
installs, it installs a version of sharp
compiled for the current version of node, if your node version changes you'll need to reinstall your node modules. I believe npm ci
installs from package-lock.json
instead of package.json
and uses specific versions so that could be the problem.
To fix this you'll need to use the same version of node in development and in your CI setup. When changing node versions, nuke node_modules
and run npm install
again to get the right version of sharp installed.
Thanks for using Gatsby! 馃挏
Please try npm rebuild sharp --force
.
Also NodeJS 9 already reached its EOL.
Thank you for opening this!
Please try the solutions given by Tyler or Daniel.
We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!
I had a problem with sharp as well. It ended up that because I had updated one plugin (gatsby-plugin-manifest) that depended on sharp, I had to update all the other plugins I was using that depended on sharp as well. Link to docs on this: https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/
That was the same issue for me, thanks @interglobalmedia. Note you can run npm list sharp
to get a list of the dependent plugins that need updating.
I had same issue on my gatsby app.
I tried
rm -rf node_modules
and then
npm install
and it worked well
Most helpful comment
Please try
npm rebuild sharp --force
.