question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: Error: Cannot resolve module 'whatwg-fetch' when building with webpack

See original GitHub issue

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 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:open
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
lougreenwoodcommented, May 29, 2019

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 bad Origin header).

Adding whatwg-fetch as a dependency isn’t ideal since I use native fetch or a polyfill on the client side (via ember-fetch) and node-fetch on server-side. So whatwg-fetch is a useless dep for me.

0reactions
mmesarcommented, Jan 1, 2019

just comment module.exports = require("whatwg-fetch"); line in browser.js file in fetch-intercept/lib folder

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found