Next.js Discord

Discord Forum

Can't resolve 'xyz' with turbopack

Unanswered
Boat-tailed Grackle posted this in #help-forum
Open in Discord
Boat-tailed GrackleOP
Module not found: Can't resolve 'fs'
1 | var fs = require('fs')
| ^^^^^^^^^^^^^
2 | var polyfills = require('./polyfills.js')
3 | var legacy = require('./legacy-streams.js')
4 | var clone = require('./clone.js')

i have got the same issue with webpack too, but i fixed that by using the following next config

  const nextConfig: NextConfig = {
      webpack: (config, { isServer }) => {
        if (isServer) {
            return config;
        }
        config.resolve.fallback = { fs: false, net: false } // don't try to import this on the client
        return config;
    }
   }
   
 


how can we tell turbopack to do exact same thing ?

0 Replies