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

我遇到了这个错误,首先我不确定它为什么会出现,其次我不确定如何解决。 错误信息:

    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 }

当沿着路径到达...axios/lib/adapters 时,有三个文件:

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

关于是否需要更改适配器文件夹中列表项 #1 and/or #3 中的代码,我希望得到一些建议。特别是在哪里。 或者是否有可以快速修复的安装。任何建议将不胜感激,如果您想查看列表项 #1 或 #3 中的代码,请告诉我。

Axios 0.27 存在这个问题。根据线程,修复程序即将推出。 对我来说,将 Axios 降级到 0.26 是可行的

npm i axio@0.26

更多信息The github thread