Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

getting .fs import error

default discord avatar
deepak_9963811 months ago
4

I was trying to use local APIs in next js - payload v3 app. Suddenly, I got this error


Module not found: Can't resolve 'fs' Did you mean './fs'? Requests that should resolve in the current directory need to start with './'.
  • default discord avatar
    notchr11 months ago

    Maybe it's because of module resolution and fs being a node specific module?



    Or perhaps there isnt a module resolution manually specified for fs?



    module.exports = {
        ...
        resolve: {
            fallback: {
                "fs": false
            },
        }
    }
  • default discord avatar
    deepak_9963811 months ago

    my next.config.mjs file looks like this


    import { withPayload } from '@payloadcms/next/withPayload' /** @type {import('next').NextConfig} */ const nextConfig = { // Your Next.js config here reactStrictMode:false, } export default withPayload(nextConfig)

    where should i add this?

  • default discord avatar
    deepak_9963811 months ago

    I don't get the option "bundler" in admin in payload.config.ts



    could it be because i'm using payload 3.0?



    I forgot to add "use server" at the top of my local API file. Adding that fixed the issue.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.