Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with postgres@3.4.0 when building for cloudflare #1967

Open
dev-cetus opened this issue Nov 29, 2023 · 2 comments
Open

Error with postgres@3.4.0 when building for cloudflare #1967

dev-cetus opened this issue Nov 29, 2023 · 2 comments

Comments

@dev-cetus
Copy link

Environment

  • node 18.17.1
  • nitro 2.7.2
  • postgres 3.4.0
  • drizzle 0.29.0

Reproduction

all code is here
on powershell, run..

$env:NITRO_PRESET='cloudflare'
pnpm run build

Describe the bug

When I build the app to deploy it to cloudflare workers, I get an error about "cloudflare:sockets" in the postgres package.
Cannot resolve "cloudflare:sockets" from "[...]\\node_modules\\.pnpm\\postgres@3.4.0\\node_modules\\postgres\\cf\\polyfills.js" and externals are not allowed!

Additional context

No response

Logs

No response

@ElioStalteri
Copy link

you can solve this by adding an additional piece in the config as follow

//https://nitro.unjs.io/config
export default defineNitroConfig({
  preset: "cloudflare-pages",
  rollupConfig: {
    external: ["cloudflare:sockets"],
  },
});

@dev-cetus
Copy link
Author

thanks it works, no more problem with cloudflare:sockets! But now I have a problem with aws-sdk (although I don't deploy on aws)

Cannot resolve "aws-sdk" from "...\\node_modules\\.pnpm\\@mapbox+node-pre-gyp@1.0.11\\node_modules\\@mapbox\\node-pre-gyp\\lib\\util\\s3_setup.js" and externals are not allowed!

I did put this configuration in, as @ElioStalteri said:

  nitro: {
    preset: "cloudflare-pages",
    rollupConfig: {
      external: ["cloudflare:sockets"],
    },
  },

majudhu added a commit to majudhu/nuxt-ui-drzzl-neon that referenced this issue Mar 18, 2024
vinayakkulkarni added a commit to vinayakkulkarni/vinayakkulkarni.dev that referenced this issue Apr 8, 2024
ref: unjs/nitro#1967 (comment)

Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants