Module not found: Error: Cannot resolve module 'whatwg-fetch' when building with webpack
See original GitHub issueI’m trying to use this as part of a webpack-based web UI. I installed it with npm install --save-dev fetch-intercept
. My code looks like:
import fetchIntercept from 'fetch-intercept';
fetchIntercept.register({
request: (url, config) => [url, config],
requestError: err => Promise.reject(err),
response: res => res,
responseError: err => Promise.reject(err)
});
in authFetchIntercept.js
and I have import './authFetchIntercept.js'
inside my javascript’s entrypoint. Trying to build the site with webpack results in:
ERROR in ./~/fetch-intercept/lib/index.js
Module not found: Error: Cannot resolve module 'whatwg-fetch' in /Users/jeffreycharles/projects/facial-recognition-webui/node_modules/fetch-intercept/lib
@ ./~/fetch-intercept/lib/index.js 261:18-41
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error: Cannot resolve module 'whatwg-fetch' when building ...
I'm trying to use this as part of a webpack-based web UI. I installed it with npm install --save-dev fetch-intercept. My code looks...
Read more >Error with Typescript / whatwg-fetch / webpack - Stack Overflow
I don't see any error in my IDE (IntelliJ IDEA) and if I change the import to some module that actually is not...
Read more >Module not found: Error: Can't resolve 'whatwg-fetch'
I'm trying to merge Cornerstone 4.8.0 into my theme and I get this error when I try to bundle or start stencil. Does...
Read more >Shimming - webpack
This means writing isolated modules that are well contained and do not rely on hidden dependencies (e.g. globals). Please use these features only...
Read more >can't resolve 'fs - You.com | The AI Search Engine You Control
Module not found : Error: Can't resolve 'fs' react js ... This GitHub repo has a listing of Node Core Libraries that Webpack...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
IMO, any upstream fix should probably also account for node-only environments where
node-fetch
is used.My use case for this project is to intercept & re-write
Origin
readers when I pre-render pages on my CI (CI would fail CORS because of badOrigin
header).Adding
whatwg-fetch
as a dependency isn’t ideal since I use native fetch or a polyfill on the client side (viaember-fetch
) andnode-fetch
on server-side. Sowhatwg-fetch
is a useless dep for me.just comment
module.exports = require("whatwg-fetch");
line in browser.js file in fetch-intercept/lib folder