Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby Build Doesn't Work Without Cache #1952

Closed
knpwrs opened this issue Aug 29, 2017 · 5 comments
Closed

Gatsby Build Doesn't Work Without Cache #1952

knpwrs opened this issue Aug 29, 2017 · 5 comments

Comments

@knpwrs
Copy link
Contributor

knpwrs commented Aug 29, 2017

Here is the source for my work-in-progress site: https://github.com/knpwrs/knpw.rs

When I run gatsby build, I get the following output:

❯ npm run build

> knpw.rs@ build /Users/knpwrs/Workspace/github.com/knpwrs/knpw.rs
> gatsby build

success delete html files from previous builds — 0.005 s
success open and validate gatsby-config.js — 0.004 s
success copy gatsby files — 0.019 s
success source and transform nodes — 0.094 s
success building schema — 0.283 s
success createLayouts — 0.007 s
error Plugin default-site-plugin returned an error


  Error: 

success createPages — 0.024 s
success createPagesStatefully — 0.025 s
GraphQL Error Unknown field `date` on type `frontmatter`

  file: /Users/knpwrs/Workspace/github.com/knpwrs/knpw.rs/src/pages/index.jsx

   1 |
   2 |   query IndexQuery {
   3 |     allMarkdownRemark(
   4 |       sort: { order: DESC, fields: [frontmatter___date] }
   5 |     ) {
   6 |       edges {
   7 |         node {
   8 |           id
   9 |           frontmatter {
  10 |             title
> 11 |             date(formatString: "MMMM DD, YYYY")
     |             ^
  12 |             path
  13 |             tags
  14 |           }
  15 |         }
  16 |       }
  17 |     }
  18 |   }
  19 |

success extract queries from components — 0.155 s
success run graphql queries — 0.002 s
success write out page data — 0.003 s
success update schema — 0.083 s

info bootstrap finished - 1.829 s

success Generating CSS — 4.858 s
success Compiling production bundle.js — 12.092 s

error Generating static HTML for pages failed

When I run gatsby develop I'll get a .cache directory which will then make gatsby build work. If I delete that cache directory then gatsby build goes back to the previous output. Is this intentional? Whats' going on?

@markmichon
Copy link
Contributor

markmichon commented Aug 29, 2017

I ran into something similar and resolved it by ensuring all of my dates in frontmatter were wrapped in quotes. Otherwise I'd have a similar issue where every other build/develop attempt would result in the error you are receiving. It's a temp fix while you're building at the very least.

I wasn't able to narrow down the underlying problem. Perhaps someone with a better understanding of the graphql setup can dig in.

edit: I think I know how to fix this in the way moment is set up. Working on it.

@knpwrs
Copy link
Contributor Author

knpwrs commented Aug 29, 2017

Looks like it is an issue with quotes. I just quoted all of my dates and it works.

@markmichon
Copy link
Contributor

markmichon commented Aug 29, 2017

Okay, so I narrowed this down further. It's not moment's fault, but rather graymatter's by way of the remark transformer. Graymatter parses a (non-string)date in YAML as a Date object, which seems to make the whole chain mad.

Going to test a fix(albeit an pretty inelegant one involving stringifying and parsing the json) on a few blogs from the readme.

If anyone knows a good reason why stripping the YAML data down to plain objects instead of instanced objects would be a bad idea for this, please let me know. If all goes smoothly I'll put a PR together.

@KyleAMathews
Copy link
Contributor

@markmichon and others check out #1964

Hadn't realized gray-matter was making date objects! Explains this weird bug.

@Jaikant
Copy link
Contributor

Jaikant commented Dec 29, 2017

I got this same error, when I used the fragment GatsbyContentfulResolutions_noBase64 in a query from the gatsby-node.js. I then replaced the fragment with the query fields and the error went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants