Gatsby: Unable to build on Netlify

Created on 21 Aug 2017  路  2Comments  路  Source: gatsbyjs/gatsby

I can run my project and build locally without seeing a single error, however when deploying to Netlify, I am seeing this error in their console:

`info bootstrap finished - 2.826 s
1:21:11 PM:
1:21:11 PM: error Generating CSS failed
1:21:11 PM:

TypeError: Cannot read property 'stats' of undefined

  • index.js:68
    [repo]/[caniuse-api]/dist/index.js:68:16

  • Array.every

  • index.js:67 isSupported
    [repo]/[caniuse-api]/dist/index.js:67:6

  • index.js:69
    [repo]/[postcss-cssnext]/lib/index.js:69:117

  • Array.forEach

  • index.js:56
    [repo]/[postcss-cssnext]/lib/index.js:56:35

  • postcss.js:150 creator
    [repo]/[postcss]/lib/postcss.js:150:35

  • webpack.config.js:182 module
    [repo]/[gatsby]/dist/utils/webpack.config.js:182:86

  • webpack.config.js:533 _callee$
    [repo]/[gatsby]/dist/utils/webpack.config.js:533:13

1:21:12 PM: Build complete: exit code: 1`

Anyone seen this at all? What is the cause?

Most helpful comment

I haven't seen that particular issue before but I have some suggestions for debugging which may help you.

The first thing to do is make sure that your local build and Netlify's build have the same inputs:

  • Make sure to use Yarn or NPM v5 and commit your yarn.lock or package-lock.json file. Yarn and NPM use these files to make the builds identical.
  • Delete node_modules (but not the lockfile) and install again. Now try building again locally and see if you get the error.
  • Delete gatsby's cache (rm -Rf .cache in your project root) and try building again.

Some other things to try:

  • Open up node_modules/caniuse-api/dist/index.js, go to line 68, and see if you figure out what's going on. That might give you some clues for what might be causing the problem.
  • Start removing parts of your code until you can deploy successfully. When it works, you know that the problem is with the last piece that you removed. If you've been using Netlify's GitHub integration then just look for the first commit with a failing deploy and see what was changed.
  • Read Netlify's debugging guide and follow their instructions for running the builder locally inside a docker container.

I hope that helps! Don't forget to comment back with what worked so other people can find your solution. 馃槃

All 2 comments

I haven't seen that particular issue before but I have some suggestions for debugging which may help you.

The first thing to do is make sure that your local build and Netlify's build have the same inputs:

  • Make sure to use Yarn or NPM v5 and commit your yarn.lock or package-lock.json file. Yarn and NPM use these files to make the builds identical.
  • Delete node_modules (but not the lockfile) and install again. Now try building again locally and see if you get the error.
  • Delete gatsby's cache (rm -Rf .cache in your project root) and try building again.

Some other things to try:

  • Open up node_modules/caniuse-api/dist/index.js, go to line 68, and see if you figure out what's going on. That might give you some clues for what might be causing the problem.
  • Start removing parts of your code until you can deploy successfully. When it works, you know that the problem is with the last piece that you removed. If you've been using Netlify's GitHub integration then just look for the first commit with a failing deploy and see what was changed.
  • Read Netlify's debugging guide and follow their instructions for running the builder locally inside a docker container.

I hope that helps! Don't forget to comment back with what worked so other people can find your solution. 馃槃

Thanks @whmountains

  • I deleted both yarn.lock and package-lock.json
  • deleted node-modules
  • Rebuilt locally and worked OK
  • Deleted the local .cache folder

Pushed the lot up and this time it built fine. So thanks for your help here. I have since deployed a small change and it's behaving still

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

andykais picture andykais  路  3Comments

timbrandin picture timbrandin  路  3Comments