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 './'.
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?
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.
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
},
}
}
Star
Discord
online
Get dedicated engineering support directly from the Payload team.