jlengstorf / netlify-plugin-gatsby-cache

185 stars 21 forks source link

Build fails when using sharp #14

Closed malaskowski closed 4 years ago

malaskowski commented 4 years ago

Hi @jlengstorf, I've tried your plugin with my Gatsby site deployed on Netlify today. I'm using sharp module to optimise images during page generation:

Part of my package.json (unfortunately the project is not public and I can't share the codebase):

"dependencies": {
    "gatsby": "^2.19.12",
     ...
    "gatsby-plugin-sharp": "^2.4.5",
     ...
  },

The Netlify build failed after I applied the plugin (according to the instruction).

1:42:50 PM: Starting Netlify Build...
1:42:53 PM: ​
1:42:53 PM: ┌─────────────────────────────┐
1:42:53 PM: │        Netlify Build        │
1:42:53 PM: └─────────────────────────────┘
1:42:53 PM: ​
1:42:53 PM: ❯ Version
1:42:53 PM:   @netlify/build 0.3.8
1:42:53 PM: ​
1:42:53 PM: ❯ Flags
1:42:53 PM:   mode: buildbot
1:42:53 PM: ​
1:42:53 PM: ❯ Current directory
1:42:53 PM:   /opt/build/repo
1:42:53 PM: ​
1:42:53 PM: ❯ Config file
1:42:53 PM:   /opt/build/repo/netlify.toml
1:42:53 PM: ​
1:42:53 PM: ❯ Context
1:42:53 PM:   production
1:42:53 PM: ​
1:42:53 PM: ❯ Installing plugins
1:42:53 PM:    - netlify-plugin-gatsby-cache
1:43:35 PM: ​
1:43:35 PM: ❯ Loading plugins
1:43:35 PM:    - netlify-plugin-gatsby-cache@0.2.1
1:43:35 PM: ​
1:43:35 PM: ┌────────────────────────────────────────────────────────┐
1:43:35 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
1:43:35 PM: └────────────────────────────────────────────────────────┘
1:43:35 PM: ​
1:43:35 PM: No Gatsby cache found. Building fresh.
1:43:35 PM: ​
1:43:35 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 6ms)
1:43:35 PM: ​
1:43:35 PM: ┌──────────────────────────────────────────────────────────────────┐
1:43:35 PM: │ 2. build.lifecycle.onBuild command from netlify.toml config file │
1:43:35 PM: └──────────────────────────────────────────────────────────────────┘
1:43:35 PM: ​
1:43:35 PM: $ yarn build
1:43:39 PM: yarn run v1.9.4
1:43:39 PM: $ npm run clean && gatsby build
1:43:39 PM: > my-blog-name@1.0.0 clean /opt/build/repo
1:43:39 PM: > gatsby clean
1:43:39 PM: info Deleting .cache, public
1:43:39 PM: info Successfully deleted directories
1:43:39 PM: Using environment config: 'production'
1:43:39 PM: success open and validate gatsby-configs - 0.095s
1:43:39 PM: error
1:43:39 PM: Something went wrong installing the "sharp" module
1:43:39 PM: Module did not self-register.
1:43:39 PM: - Remove the "node_modules/sharp" directory, run "npm install" and look for errors
1:43:39 PM: - Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
1:43:39 PM: - Search for this error at https://github.com/lovell/sharp/issues
1:43:39 PM: not finished load plugins - 0.196s
1:43:39 PM: error Command failed with exit code 1.
1:43:39 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1:43:39 PM: ​
1:43:39 PM: ┌─────────────────────────────┐
1:43:39 PM: │        Build failed         │
1:43:39 PM: └─────────────────────────────┘
1:43:39 PM: ​
1:43:39 PM:   Error message
1:43:39 PM:   Command failed with exit code 1: yarn build
1:43:39 PM: ​
1:43:39 PM:   Error location
1:43:39 PM:   In configuration "build.lifecycle.onBuild" command:
1:43:39 PM:   yarn build
1:43:39 PM: ​

After I removed the plugin from netlify.toml the Netlify builds work again.

Generating images renditions is the main part of the build process of my website. Is that a known issue? Maybe some hints how I can fix it?

jlengstorf commented 4 years ago

hey, @Skejven

the error looks like a corrupted node_modules build, so I think you may be able to fix it with a "Clear Cache & Deploy"

if that doesn't clear it up, try a yarn upgrade, which will change your lockfile and trigger Netlify to build the latest versions of the dependencies

let me know if that doesn't fix it!

malaskowski commented 4 years ago

Thank you @jlengstorf , yarn upgrade fixed my problem (rebuilding with cleared cache didn't).

jlengstorf commented 4 years ago

great to hear! thanks for following up!