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

Preset cloudflare not ignoring optional require() #293

Closed
zendagin opened this issue Jun 15, 2022 · 4 comments
Closed

Preset cloudflare not ignoring optional require() #293

zendagin opened this issue Jun 15, 2022 · 4 comments

Comments

@zendagin
Copy link

Environment

node v16.14.2
nitropack 0.4.7

Reproduction

https://stackblitz.com/edit/github-dfijad?file=nuxt.config.ts

run npm run build

Describe the bug

Default preset works well when building with package with optional require() (in my case, mogodb)., but not with preset cloudflare.

It throws

ERROR Rollup error: Cannot resolve "snappy/package.json" from "/home/projects/github-dfijad/node_modules/mongodb/lib/deps.js" and externals are not allowed!

ERROR Cannot resolve "snappy/package.json" from "/home/projects/github-dfijad/node_modules/mongodb/lib/deps.js" and externals are not allowed!

Additional context

Code snap from mongodb sdk

try {
  // Ensure you always wrap an optional require in the try block NODE-3199
  Snappy = require('snappy');
  try {
    (Snappy as any)[PKG_VERSION] = parsePackageVersion(require('snappy/package.json'));
  } catch {} // eslint-disable-line
} catch {} // eslint-disable-line

Logs

No response

@shiftlabs1
Copy link

I am experiencing thesame issue as above . thing is i can not even tell what is causing the error. the package referred to does not exist in my project

@warflash
Copy link

Same issue with the Cloudflare preset here :/

@victorkwok97
Copy link

Same issue when upgraded nuxt to 3.0.0-rc.8-27699522.e38e1de
https://stackblitz.com/edit/github-dfijad-x7236k?file=nuxt.config.ts,app.vue,package.json

@pi0
Copy link
Member

pi0 commented Feb 16, 2023

MongoDB is not compatible with worker platforms. Please follow up via #949

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants