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

adapters now require node-fetch to be a dependency of the app #1076

Closed
Rich-Harris opened this issue Apr 17, 2021 · 6 comments
Closed

adapters now require node-fetch to be a dependency of the app #1076

Rich-Harris opened this issue Apr 17, 2021 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@Rich-Harris
Copy link
Member

Describe the bug
Unanticipated side-effect of #1066node-fetch isn't available when the app is built on e.g. Netlify:

image

We could make it a peer dependency of the adapters, but that would suck. I think it might be better if adapters took responsibility for bundling the output of svelte-kit build (with eg. esbuild — this functionality could also be exposed via the adapter utils). Then, if we exposed something like @sveltejs/kit/install-fetch for the relevant adapters to use (rather than expecting them to use the correct version of node-fetch and correctly assign the relevant bits to globalThis), it wouldn't mean needing @sveltejs/kit to be a production dependency.

Severity
Completely blocks use of the affected adapters, AFAICT

@chrisabruce
Copy link

I am hit by this as well trying to deploy to Netlify. Is there any kind of work around?

{"errorType":"Error","errorMessage":"Cannot find package 'node-fetch' imported from /var/task/src/handler.mjs","trace":["Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-fetch' imported from /var/task/src/handler.mjs","    at packageResolve (internal/modules/esm/resolve.js:650:9)","    at moduleResolve (internal/modules/esm/resolve.js:691:18)","    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:784:11)","    at Loader.resolve (internal/modules/esm/loader.js:100:40)","    at Loader.getModuleJob (internal/modules/esm/loader.js:246:28)","    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:47:40)","    at link (internal/modules/esm/module_job.js:46:36)"]}

@Rich-Harris Rich-Harris added the bug Something isn't working label Apr 17, 2021
@Rich-Harris
Copy link
Member Author

  1. downgrade
  2. installing node-fetch as a prod dependency in your app might fix it?

@zommerberg
Copy link
Contributor

Weirdly I have the same problem now, neither a downgrade or installing the node-fetch as prod dependency fixes it.

@zommerberg
Copy link
Contributor

zommerberg commented Apr 18, 2021

Working fine after upgrading to "@sveltejs/adapter-netlify": "^1.0.0-next.7" and "@sveltejs/kit": "1.0.0-next.80"

@mcurcija
Copy link

Working fine after upgrading to "@sveltejs/adapter-netlify": "^1.0.0-next.7" and "@sveltejs/kit": "1.0.0-next.80"

I can confirm this as well. It also should be noticed that netlify-adapter now uses .netlify subdirectory so netlify.toml should be updated accordingly. The "node-fetch" dependency should be removed completely as in sveltejs/realworld.

@Rich-Harris
Copy link
Member Author

This should be fixed now — #1091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants