-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
axios v0.27.0 uses node polyfills provided by webpack, which are removed from webpack v5 #4623
Copy link
Copy link
Closed
Description
Describe the bug
I'm using axios in an app created by create-react-app. As soon I upgraded axios to v0.27.0, the application stop working with the error shown in the reproduction section. Downgrading to v0.26.1 solved the issue.
It looks like the issues rises from the xhr adapter.
To Reproduce
Create an empty project using CRA
npx create-react-app my-app
cd my-appinstall axios
npm install axiosuse axios to make any request
useEffect(() => {
axios.get("https://google.com");
}, []);start the application
npm startThe error is shown in the console
Module not found: Error: Can't resolve 'url' in '/home/mayo/personal-projects/my-app/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 }
ERROR in ./node_modules/axios/lib/adapters/xhr.js 17:10-24
Module not found: Error: Can't resolve 'url' in '/home/mayo/personal-projects/my-app/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 }
webpack compiled with 1 errorExpected behavior
That it works, or at least there are instruction to install the dependencies in the documentation.
Environment
- Axios Version 0.27.0
- Additional Library Versions create-react-app (react-scripts) v5 / webpack v5
Additional context/Screenshots
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels