Home > database >  Error: module not found in React, cannot resolve 'url' in ...axios/lib/adapters
Error: module not found in React, cannot resolve 'url' in ...axios/lib/adapters

Time:05-03

I'm getting this error and am not sure firstly why it appears and secondly how to resolve. the error message:

    Compiled with problems:X

ERROR in ./node_modules/axios/lib/adapters/xhr.js 17:10-24

Module not found: Error: Can't resolve 'url' in '/Users/tobiasbedford/Documents/sei/lexicon/lexicon-coding-challenge/node_modules/axios/lib/adapters'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
    - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "url": false }

when following the path to ...axios/lib/adapters there are three files:

  1. http.js
  2. README.md
  3. xhr.js

I would love some advise on whether I need to change the code in list items #1 and/or #3 in the adapters folder. And where particularly. Or whether there is an install that would be a quick fix. Any advise would be much appreciated and please let me know if you'd like to view the code in list items #1 or #3.

CodePudding user response:

This problem exists with Axios 0.27. As per the thread, a fix is coming soon. For me downgrading Axios to 0.26 works

npm i [email protected]

For more info The github thread

  • Related