Netlify constantly builds gatsby failed: "Cannot find module '../build/Release/sharp-linux-x64.node"

I’m having a problem with gatsby build when deploying on Netlify. So the error looks like this:

12:35:40 PM:   Error: Something went wrong installing the "sharp" module
12:35:40 PM:   Cannot find module '../build/Release/sharp-linux-x64.node'
12:35:40 PM:   Require stack:
12:35:40 PM:   - /opt/build/repo/node_modules/sharp/lib/sharp.js
12:35:40 PM:   - /opt/build/repo/node_modules/sharp/lib/constructor.js
12:35:40 PM:   - /opt/build/repo/node_modules/sharp/lib/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby-plugin-sharp/safe-sharp.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby-plugin-sharp/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby-plugin-sharp/gatsby-node.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js  - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plug  in.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby-cli/lib/create-cli.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby-cli/lib/index.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
12:35:40 PM:   - /opt/build/repo/node_modules/gatsby/cli.js
12:35:40 PM:   Possible solutions:
12:35:40 PM:   - Install with verbose logging and look for errors: "npm install --ignore-scri  pts=false --foreground-scripts --verbose sharp"
12:35:40 PM:   - Install for the current linux-x64 runtime: "npm install --platform=linux --a  rch=x64 sharp"
12:35:40 PM:   - Consult the installation documentation: https://sharp.pixelplumbing.com/inst  all

I found a similar topic on this forum here. I made some changes in NODE_VERSION varying from 14.15 (the minimum for my project) to the latest node version, but none of them really solves the problem.

Some issues were, or are opened on Github about the same problem but all of them are for developing at local machines. The accepted solution is mostly rm -rf node_modules *-lock.json and reinstall the node dependencies but I don’t think I have that in Netlify environment.

#18277
#20957
#3086

When I develop and build in my local machine, there is no error whatsoever but when Netlify tries to build and deploy, the error occurs.

I’m not sure what information to solve this issue, so I’m gonna keep it short. However, I’m happy to provide more if needed.

Thank you!

Hey there, @richardnguyen99 :wave:

Thanks for reaching out, and welcome to the Netlify Forums! Can you please share a link to your site as well as the full deploy log from your most recent build? This will help us look into this further.

Thanks!

Hi,

This is the full site for my latest build. https://app.netlify.com/sites/spiffy-concha-bdc080/deploys/62e43636e5c279372da6cbdb

Please let me know if you have any trouble with it.

Hi @richardnguyen99,

Thanks for the additional information.

Since you changed node versions, can you try rebuilding the site after clearing the cache. This can be achieved by selecting the following option Clear cache and deploy site from the Trigger deploy pane on the Deploy page. This can be found on the opposite side of the Search Deploys field.

Please then let us know your results.

Hi @Melvin,

I tried that as well. Nothing changed. I even deleted the repository on Netlify and redid the whole site setting again but it seems to me there is an internal error with Netlify.

I has been using Netlify and the same configuration since I first started this project and somehow one day, it doesn’t work anymore.

I have also imported my repository to other clouds like Vercel and Gatsby Cloud. Both of them works just fine to me.

Hey there, @richardnguyen99 :wave:

Thanks for reaching out. As you have redone the site, I cannot see anything when I follow the link to your failed deployed.

I have taken a look at some of your deploy logs on your account though, and it looks like one of your sites is using an outdated gatsby plugin. (Looking here)-- can you update your gatsby plugin as well as the node version that is supported, and try deploying again?

Thanks!

Hi @hillary,

Thank you for your time. I totally forgot that you couldn’t view the log when I redid the site.

Depsite your suggestion, none of them really fixed the problem. Here’s the latest log from the current project:

The ones you mentioned are old and I’m no longer working on them.

Unfortunately, I need to see my app in production after I finish a feature. But this bug has been preventing me from doing for like 5 days. I have to migrate to another cloud platform to continue the project.

If you need any more information, please let me know and I’ll see what I can do.

Hi @richardnguyen99,

I’m not able to see the deploy at Netlify App either. It appears the site has been deleted.

I understand that you’ve migrated to another platform. If you do want to continue to troubleshoot the issue, please let us know.

Hi @Melvin,

I’m not sure the link keeps getting not found error. Here is the latest build log from my project. I have created a new site for the purpose of troubleshooting this issue.

I have used Netlify for a long time and I have to migrate to another platform reluctantly. So I would love to help your team figure out what’s happening.

Hi @richardnguyen99

Thanks for sharing the latest build log.

We deployed a fresh cone of the repo and using only the flag --legacy-peer-deps we were able to successfully deploy. Could you try deploying while only using --legacy-peer-deps and see if you’re still having issues?

Oh hey, it works! Thank you @Melvin.

I didn’t know why --ignore-scripts was the culprit because I used it from the beginning.

1 Like