[ERROR] Error: No such module "chunks/pages/buffer".

I'm getting a [ERROR] Error: No such module "chunks/pages/buffer". error that I cannot for the life of me debug or source where it's coming from. My application is an Astro Pages app that definitely makes use of Buffer on the server side and I've tried bot stubbing in a buffer package as well as using compatibility_flags = [ "nodejs_compat" ] all to no avail. I cannot get past this issue when running a function that utilizes the Buffer package. Here's what my current astro.config.mjs looks like
import { defineConfig } from 'astro/config'
import cloudflare from "@astrojs/cloudflare"
import svelte from "@astrojs/svelte"
import inject from '@rollup/plugin-inject'
import tailwind from "@astrojs/tailwind"

// https://astro.build/config
export default defineConfig({
output: "server",
adapter: cloudflare({
imageService: 'passthrough',
platformProxy: {
enabled: true,
persist: true,
}
}),
vite: {
ssr: {
external: ['node:buffer']
},
build: {
rollupOptions: {
plugins: [
inject({
modules: { Buffer: ['node:buffer', 'Buffer'], }
})
],
},
},
},
integrations: [tailwind(), svelte()]
})
import { defineConfig } from 'astro/config'
import cloudflare from "@astrojs/cloudflare"
import svelte from "@astrojs/svelte"
import inject from '@rollup/plugin-inject'
import tailwind from "@astrojs/tailwind"

// https://astro.build/config
export default defineConfig({
output: "server",
adapter: cloudflare({
imageService: 'passthrough',
platformProxy: {
enabled: true,
persist: true,
}
}),
vite: {
ssr: {
external: ['node:buffer']
},
build: {
rollupOptions: {
plugins: [
inject({
modules: { Buffer: ['node:buffer', 'Buffer'], }
})
],
},
},
},
integrations: [tailwind(), svelte()]
})
1 Reply
kalepail
kalepailOP9mo ago
Apps works fine locally as well as running with wrangler pages dev ./dist. It's only after I deploy that I get this issue Got it!
...
export default defineConfig({
...
vite: {
...
resolve: {
alias: {
'buffer': 'node:buffer'
}
},
...
},
...
})
...
export default defineConfig({
...
vite: {
...
resolve: {
alias: {
'buffer': 'node:buffer'
}
},
...
},
...
})
Want results from more Discord servers?
Add your server