错误:在 React 中找不到模块,无法'url'解析 ...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和/或#3中的代码。尤其是在哪里。或者是否有一个安装可以快速修复。如有任何建议,我将不胜感激,如果您想查看列表项目#1或#3中的代码,请告诉我。

Axios 0.27存在此问题。根据线程,一个修复即将到来。对我来说,将Axios降级到0.26行得通

npm i axio@0.26

github线程

相关内容

  • 没有找到相关文章

最新更新