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.

Adding WPGraphQL produces Error: Cannot find module 'react'

See original GitHub issue

Description

When adding WPGraphQL to a working basic Gatsby install, gatsby develop produces Error: Cannot find module 'react'

Steps to reproduce

  1. Create new gatsby site gatsby new test-wpgraphql and cd to that directory.
  2. Run gatsby develop and confirm the site is built properly at http://localhost:8000/
  3. Install WPGraphQL (npm install --save gatsby-source-graphql)
  4. Update gatsby-config.json with the following: { resolve: 'gatsby-source-graphql', options: { typeName: 'WPGraphQL', fieldName: 'wpgraphql', url: 'https://gatsbywpsource.local/graphql', //url: 'https://www.wpgraphql.com/graphql', refetchInterval: 60 }, },
  5. Run gatsby develop

Expected result

Instead of a live Gatsby site with GraphQL integration to the WordPress source, the console throws the following error:

Actual result

Error: Cannot find module ‘react’ Require stack:

  • /Users/dlindberg/Code/test-wpgraphql/node_modules/ink/build/instance .js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/ink/build/render.j s
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/ink/build/index.js - /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/node_module s/gatsby-cli/lib/reporter/loggers/ink/index.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/node_module s/gatsby-cli/lib/reporter/index.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/schema /types/type-defs.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/redux/ reducers/inference-metadata.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/redux/ reducers/index.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/redux/ index.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/utils/ gatsby-dependents.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/utils/ webpack.config.js
  • /Users/dlindberg/Code/test-wpgraphql/node_modules/gatsby/dist/comman ds/develop.js
  • /usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js
  • /usr/local/lib/node_modules/gatsby-cli/lib/index.js

Environment

System: OS: macOS 10.15.4 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.12.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.11.3 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 80.0.3987.163 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-filesystem: ^2.2.2 => 2.2.2 gatsby-source-graphql: ^2.4.0 => 2.4.0 gatsby-transformer-sharp: ^2.4.3 => 2.4.3 npmGlobalPackages: gatsby-cli: 2.11.8

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Dave-Lindbergcommented, Apr 18, 2020

@wardpeet Thank you, installing with yarn fixed the issue! Gatsby develop now runs properly. 😃

0reactions
github-actions[bot]commented, May 20, 2020

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module 'react' - after installing Plugin · Issue ...
This occurred for me when I added gatsby-plugin-sass via npm . The following steps helped fix the issue: rm -Rf node_modules package-lock.json ...
Read more >
Cannot find module 'react' from 'react-common.cjs.js' when ...
I have a problem when testing a compenent that uses a custom graphql Mutation Hook generated with Apollo Tooling. The mututation hook comes ......
Read more >
Using Custom Post Type UI - WPGraphQL
In order to use Custom Post Types with WPGraphQL, you must configure the Post Type to show_in_graphql using the following fields: show_in_graphql |...
Read more >
How to Add Custom Fields in Headless WordPress with ACF ...
Read How to Add Custom Fields in Headless WordPress with ACF & WPGraphQL at Space Jelly.
Read more >
How To Use WordPress Content with a Gatsby.js Application
To verify that the GraphQL connection will be available for connecting to Gatsby, open the Settings panel, under the GraphQL sub-section in the ......
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