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

How to disable non-node environment warning in cloudflare workers #130

Open
zou-yu opened this issue Sep 29, 2024 · 2 comments
Open

How to disable non-node environment warning in cloudflare workers #130

zou-yu opened this issue Sep 29, 2024 · 2 comments

Comments

@zou-yu
Copy link

zou-yu commented Sep 29, 2024

Environment

nodejs 20

Reproduction

no need

Describe the bug

"[node-fetch-native] Node.js compatible build of `node-fetch-native` is being used in a non-Node.js environment. Please make sure you are using proper export conditions or report this issue to https://github.com/unjs/node-fetch-native. You can set `process.env.DISABLE_NODE_FETCH_NATIVE_WARN` to disable this warning."

In cloudflare worker, there is no process.env or environment variables, so how can I set DISABLE_NODE_FETCH_NATIVE_WARN to disable this warning. Or any other solution to disable this warning

Additional context

No response

Logs

No response

@zou-yu zou-yu added the bug Something isn't working label Sep 29, 2024
@pi0 pi0 removed the bug Something isn't working label Sep 29, 2024
@pi0
Copy link
Member

pi0 commented Sep 29, 2024

Can you please share a full reproduction repo? I guess this resolution issue is not originating from this library. (and it is important issue!)

@oxcabe
Copy link

oxcabe commented Jan 2, 2025

Hi! This was happening to me as well, trying to run the wrangler dev server on a Nuxt project (with nitro preset cloudflare_module).

I ended up finding out that one of my dependencies, "@builder.io/sdk-vue": "^3.0.1", was using node-fetch, which I think was messing with the resolutions.

They have this repo trying to explain their reasoning on this matter: https://github.com/BuilderIO/this-package-uses-fetch

Anyway, the solution I used was to override node-fetch using pnpm specific settings in package.json, which ended up looking similarly to:

  "dependencies": {
    "node-fetch-native": "^1.6.4"
  },
  "pnpm": {
    "overrides": {
      "node-fetch": "$node-fetch-native"
    }
  }

Additionally, another solution that wouldn't require pnpm and would exclusively apply to the worker would be to set an alias inside wrangler.toml.

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

3 participants