question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After cleaning cache ""gatsby-node.js" threw an error while running the createPagesStatefully lifecycle"

See original GitHub issue

Description

Hey,

Just today my gatsby installation stopped working (I’ve cleaned cache). I get the following error: Enum type WPGraphQL_LanguageCodeEnum must define one or more values.

Steps to reproduce

Clear steps describing how to reproduce the issue. Please please please link to a demo project if possible, this makes your issue much easier to diagnose (seriously).

My gatsby-node.js:

` const createPages = require(“./create/createPages”)

exports.createPagesStatefully = async ({ graphql, actions, reporter }, options) => { await createPages({ actions, graphql, reporter }, options) } `

And createPages: ` const pageTemplate = require.resolve(“…/src/templates/page.js”)

const GET_PAGES = query GET_PAGES($first:Int $after:String) { wpgraphql { pages( first: $first after: $after # This will make sure to only get the parent nodes and no children where: { parent: null } ) { pageInfo { hasNextPage endCursor } nodes { id title pageId uri isFrontPage } } } }

const allPages = [] let pageNumber = 0 const itemsPerPage = 10

/**

  • This is the export which Gatbsy will use to process.
  • @param { actions, graphql }
  • @returns {Promise<void>} */ module.exports = async ({ actions, graphql, reporter }, options) => {

/**

  • This is the method from Gatsby that we’re going

  • to use to create pages in our static site. / const { createPage } = actions /*

  • Fetch pages method. This accepts variables to alter

  • the query. The variable first controls how many items to

  • request per fetch and the after controls where to start in

  • the dataset.

  • @param variables

  • @returns {Promise<*>} / const fetchPages = async (variables) => /*

    • Fetch pages using the GET_PAGES query and the variables passed in. / await graphql(GET_PAGES, variables).then(({ data }) => { /*
      • Extract the data from the GraphQL query results */ const { wpgraphql: { pages: { nodes, pageInfo: { hasNextPage, endCursor }, }, }, } = data

    /**

    • Map over the pages for later creation */ nodes && nodes.map((pages) => { allPages.push(pages) })

    /**

    • If there’s another page, fetch more
    • so we can have all the data we need. */ if (hasNextPage) { pageNumber++ reporter.info(fetch page ${pageNumber} of pages...) return fetchPages({ first: itemsPerPage, after: endCursor }) }

    /**

    • Once we’re done, return all the pages
    • so we can create the necessary pages with
    • all the data on hand. */ return allPages })

/**

  • Kick off our fetchPages method which will get us all
  • the pages we need to create individual pages. */ await fetchPages({ first: itemsPerPage, after: null }).then((wpPages) => {
wpPages && wpPages.map((page) => {
  let pagePath = `${page.uri}`

  /**
   * If the page is the front page, the page path should not be the uri,
   * but the root path '/'.
   */
  if(page.isFrontPage) {
    pagePath = '/'
  }

  createPage({
    path: pagePath,
    component: pageTemplate,
    context: {
      id: String(page.pageId)
    },
  })

  reporter.info(`page created: ${pagePath}`)
})

reporter.info(`# -----> PAGES TOTAL: ${wpPages.length}`)

}) } `

2 hours ago everything worked properly, any idea what could have happend?

Expected result

Gatsby develop and build commands will work properly.

Actual result

Nothing to add than description above, sorry.

Environment

System: OS: macOS 10.15.4 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.10.1 - /usr/local/bin/node npm: 6.14.4 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 80.0.3987.163 Firefox: 70.0.1 Safari: 13.1 npmPackages: gatsby: ^2.20.12 => 2.20.12 gatsby-image: ^2.3.1 => 2.3.1 gatsby-plugin-manifest: ^2.3.3 => 2.3.3 gatsby-plugin-offline: ^3.1.2 => 3.1.2 gatsby-plugin-react-helmet: ^3.2.1 => 3.2.1 gatsby-plugin-sharp: ^2.5.3 => 2.5.3 gatsby-source-graphql: ^2.1.25 => 2.3.2 gatsby-transformer-sharp: ^2.4.3 => 2.4.3 npmGlobalPackages: gatsby-cli: 2.11.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mmazurowskicommented, Apr 9, 2020

@jasonbahl You were absolutely right, seems this issue was not directly caused by gatsby itself. Thank you all for your help and sorry for the trouble! Be safe, be in health, keep on being awesome!

😃

0reactions
jasonbahlcommented, Apr 9, 2020

@ktw-studio I’m going to close this issue in favor of the issue/PR I’ve opened on the WPGraphQL for Polylang repo:

Read more comments on GitHub >

github_iconTop Results From Across the Web

"gatsby-node.js" threw an error while running the createPages ...
“gatsby-node.js” threw an error while running the createPages lifecycle: createPage is not defined. 27 | const posts = postsQuery.data.
Read more >
Error "gatsby-node.js" threw an error while running the ...
Hi all, sinds a few days I am getting this error while building. I can't help it, could someone help me out with...
Read more >
Gatsby Node APIs
Documentation on Node APIs used in Gatsby build process for common uses like creating pages.
Read more >
gatsby develop throws allMdx error since upgrading npm ...
File: gatsby-node.js:40:5 ERROR #11321 PLUGIN "gatsby-node.js" threw an error while running the createPages lifecycle: Cannot query field ...
Read more >
Understanding the lifecycle of Gatsby - EQOLOT
When you start a new Gatsby project, you will notice the usual React code, ... as gatsby-config.js , gatsby-node.js , gatsby-browser.js , and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found