Search code examples
reactjstypescriptgraphqlnext.jsapollo

error - ./node_modules/busboy/lib/main.js:1:0 Module not found: Can't resolve 'fs'


When I add a new React component to my NextJS app (React, TypeScript and GraphQL), my local development environment suddenly breaks with this cryptic error:

wait  - compiling...
error - ./node_modules/busboy/lib/main.js:1:0
Module not found: Can't resolve 'fs'
null

When I stash my new component, everything works fine. I'm trying to figure out what it is in my new component that's triggering this error.

Relevant dependencies:

  • @apollo/client: ^3.2.5
  • apollo-server-micro: ^2.18.2
  • graphql: ^15.4.0
  • next: 10.0.0
  • react: 17.0.1
  • react-dom: 17.0.1

Solution

  • Turns out I was importing gql from the wrong package. As I'm building both the server and the client in one app, I have to be careful importing the right methods from the right packages.

    This line from my imports caused the error:

    import { gql } from "apollo-micro-server

    Changing the line to this fixed the error:

    import { gql } from "@apollo/client"