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

Error was not caught ReferenceError: require is not defined with 7.0 #5238

Closed
joaogarin opened this issue Sep 20, 2018 · 4 comments · Fixed by #5242
Closed

Error was not caught ReferenceError: require is not defined with 7.0 #5238

joaogarin opened this issue Sep 20, 2018 · 4 comments · Fixed by #5242

Comments

@joaogarin
Copy link

Examples bug report

Example name

With apollo

Describe the bug

VM64:37 Error was not caught ReferenceError: require is not defined
at Module../node_modules/graphql/jsutils/instanceOf.mjs (instanceOf.mjs:31)

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to https://github.com/zeit/next.js/tree/canary/examples/with-apollo
  2. clone and npm install
  3. Launch site on http://localhost:3000
  4. See error

I can imagine other apollo examples also have the same issue after 7.x

Expected behavior

No errors.

Screenshots

screen shot 2018-09-20 at 16 57 34

System information

  • OS: [macOS]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: [e.g. 7.0.0]

Additional context

Only happens when trying out 7.0. It seems related to webpack4 and the support on .mjs files..it could be also an issue with graphql-js, I cant really find anything there. maybe someone else can help finding this out..will gladly move issue there if thats the case. Also dont know if at this point 7.0 is stable..just wanted to see how bad an upgrade would be, probably still a bit soon for me ;)

amytych added a commit to amytych/next.js that referenced this issue Sep 21, 2018
Fixes the example with next.js@7

Fixes vercel#5238
@amytych
Copy link
Contributor

amytych commented Sep 21, 2018

I solved it by updating graphql, it's quite outdated in this example. I sent a PR #5242 to fix it.

@joaogarin
Copy link
Author

awesome, yeah I though graphql dependency was coming from react-apollo, but y that totally works tks 👍 cheers

timneutkens pushed a commit that referenced this issue Sep 21, 2018
Fixes the example with next.js@7

Fixes #5238
piglovesyou added a commit to piglovesyou/react-starter-kit that referenced this issue Nov 6, 2018
* npm graphql requires to be update
vercel/next.js#5238 (comment)
@alexindigo
Copy link
Contributor

We had exactly same issue, and upgrading graphql version didn't help (at first), so we spent quite some time investigating, until we've found that one of the dependency of our dependency had it's own copy of graphql that was older version – that package had graphql as dependency instead of listing it as peerDependency. After it was fixed everything went back to normal.

In case anybody else would be struggling with the same issue.

langpavel pushed a commit to kriasoft/react-starter-kit that referenced this issue Feb 19, 2019
* Upgrade all dependencies

1. ncu --upgradeAll
4. Leave "graphql" to be "^13.2.0" that apollo packages depend on
2. Apply patch of "npx babel-upgrade" output
3. Leave only necessary babel plugins
4. Pass "yarn fix" by disabling stricter rules

* Pass "req" through GraphQL resolver context

* Through rootValue it cannot be passed from browser GraphQL access
* rm unnecessary code

* Add "Timestamp" scalar type for convinience

* rm unnecessary files

* fix: Timestamp didn't work

* npm graphql requires to be update
vercel/next.js#5238 (comment)

* Feature: Codegen from GraphQL schema and use more Flow types (#2)

* install apllo

* add apollo.config.js

* apollo codegen succeeded

* fix: updateNetworkStatus signature

* rm @flow from files not ready

* add flow-typed files

* done: Using auto-generated types works

* flow-bin@0.89+ has regression. Use ^0.88.0.

* fix: invalid GraphQL primitive types

* Add codegen script

* done: import auto-generated file

* refac: move impl for apollo-link-state to graphql dir as same as server side resolvers

* codegen and ignore eslint these files

* refactor: "networkStatus"

* feat: codegen:standalone

* refac: "OnMemoryState" is what I meant

* Improve codegen (#3)

* delete existing auto-generated types

* change script name

* ignore __generated__ folder

* wip: disallow absolute path resolving under `src` dir

* It causes disregard .js type checking under src

* fix all flow error

* modify: prevent `withStyles` drops component type

* Modify targe Node versions

* Fix build failure: Codegen before lint

* Add Node v10 LTS for build target
@ofarukcaki
Copy link

I don't have graphql but still I get the error

@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants