By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the bug

I'm trying to install Axios 0.27.0 with React, but when I run npm start I get this error:

Module not found: Error: Can't resolve 'url' in '/path/to/node_modules/axios/lib/adapters'

To Reproduce

Run npm i axios in your terminal, and npm start, and then in your App.js:

import axios from "axios"

Expected behavior

App running normally

Environment

  • Axios Version [0.27.0]
  • Adapter [e.g. XHR/HTTP]
  • Browser [Chrome]
  • Browser Version [100.0.4896.127]
  • Node.js Version [16.13.1]
  • OS: [macOS 12.3.1]
  • Additional Library Versions [React 18.0.0]
  • Additional context/Screenshots

  • Browser [Chrome] Version 100.0.4896.127
  • S.O = Windows 10
  • Additional Library Versions [Vue 3.2.33]
  • P.D: url = requiere('url') << this import (module) only works in NODE, or am I wrong?

    axios/lib/adapters/xhr.js Line 10 cdd7add Jiaocz, mustavikhan05, razr130, muammarFaiz, Lucas-jimenez-dev, carlosyahircc, and hahoang1903 reacted with thumbs up emoji Jiaocz, mustavikhan05, and muammarFaiz reacted with hooray emoji All reactions

    React Native ERROR [Error: undefined Unable to resolve module url from /node_modules/axios/lib/adapters/xhr.js

    I'm getting the same. Rolling back to 0.26.0 resolved it for the time being.