• Resolved justinblayney

    (@justinblayney)


    hello,

    newbie here,

    I am using the Next.js wordpres template, it has me install your plugins, im tryign to use it to generate my nav.. this is my error

    ./components/nav.js:2:0
    Module not found: Can’t resolve ‘gatsby’
    1 | import React from “react”
    > 2 | import { graphql } from “gatsby”
    3 |
    4 | const MainNav = ({ data }) =>

    {JSON.stringify(data, null, 4)}

    5 |

    I installed Gatsby, I did a version chek

    MacBook-Pro:cms-wordpress-app justin$ gatsby -v
    Gatsby CLI version: 2.16.0

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jason Bahl

    (@jasonbahl)

    Hello Justin!

    Thanks for checking out WPGraphQL! Excited to have you exploring using WPGraphQL with modern JavaScript front-ends.

    It looks like you’re trying to use Next.JS combined with Gatsby. Gatsby and Next are both JavaScript frameworks that largely aim to solve similar problems, but in different ways.

    While it might be possible in some cases to use Gatsby and Next together, it’s likely very uncommon.

    I’d recommend sticking with Next or Gatsby instead of trying to combine them in one project.

    To get started with Gatsby + WPGraphQL, I recommend starting here: https://www.gatsbyjs.com/guides/wordpress/

    To get started with Next + WPGraphQL, I recommend this tutorial: https://dev.to/kendalmintcode/configuring-wordpress-as-a-headless-cms-with-next-js-3p1o

    Thread Starter justinblayney

    (@justinblayney)

    Hello Jason,

    I am using the Next.js wordpress headless template, which recommends your plugin and has it as part of the install https://github.com/vercel/next.js/tree/canary/examples/cms-wordpress

    So when I try too get the code for a menu (see below), Gatsby is build into your plugin, is there anyway to switch it it next in the settings? Os do I just change the import to something?

    import React from "react"
    import { graphql } from "gatsby"
    
    const ComponentName = ({ data }) => <pre>{JSON.stringify(data, null, 4)}</pre>
    
    export const query = graphql

    {
    menu(id: “188”)
    menuItem(id: “”) {
    childItems {
    nodes {
    path
    url
    title
    childItems
    }
    }
    url
    title
    path
    }
    }

    export default ComponentName`

    Thread Starter justinblayney

    (@justinblayney)

    when i check the next node_modules, there is no module for WPGraphQL in Next like there is for Gatsby

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Module not found: Can’t resolve ‘gatsby’’ is closed to new replies.