Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Impossible to use Axios 0.27.0 with React #4621

Closed
JulSeb42 opened this issue Apr 25, 2022 · 19 comments
Closed

Impossible to use Axios 0.27.0 with React #4621

JulSeb42 opened this issue Apr 25, 2022 · 19 comments

Comments

@JulSeb42
Copy link

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

None

@pdanpdan
Copy link

I also have something related (on v0.27.0)
All GET calls throw an error url.parse is not a function at

var parsed = url.parse(fullPath);

Ubuntu 22.04 / Chrome Beta

@WillianPadilha
Copy link

WillianPadilha commented Apr 25, 2022

I also have something related (on v0.27.0) All GET calls throw an error url.parse is not a function at

var parsed = url.parse(fullPath);

Ubuntu 22.04 / Chrome Beta

Same issue with Vue 3 + SPA

  • Node v14.19.0
  • Vite 2.9.1
  • Axios Version [0.27.0]
  • 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?

var url = require('url');

@TheSeg
Copy link

TheSeg commented Apr 25, 2022

Can confirm in Vue 3 + SPA, Axios is broken due to the use of url.

@diego-paired
Copy link

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

@skelawsky
Copy link

skelawsky commented Apr 25, 2022

Run: npm i url. Error is due to: 4594

Jiaocz added a commit to Jiaocz/http3checker that referenced this issue Apr 26, 2022
@mustavikhan05
Copy link

Same issue

@mxp131011
Copy link

So did I

@AllenTan005
Copy link

same here on vue 2

@mustavikhan05
Copy link

Same issue

Run: npm i url. Error is due to: 4594

Run: npm i url. Error is due to: 4594

This worked! Thank you so much!

@luiScolari
Copy link

Run: npm i url. Error is due to: 4594

Work for me, thanks!

@TheSeg
Copy link

TheSeg commented Apr 26, 2022

Having to install an additional library not maintained by Node is not a workable solution.

@Jplus2
Copy link

Jplus2 commented Apr 26, 2022

got the same issue here using React

@nathangroblewski
Copy link

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.

@play-station
Copy link

play-station commented Apr 26, 2022

same issue with RN, hope you release v0.27.1 soon

@challengy1
Copy link

I've encountered the same issue with React Native.

@jasonsaayman
Copy link
Member

I am releasing a new version asap to fix this issue

@zain-khalid
Copy link

@challengy1 Did your error resolve in the new version?
Bugsnag this error on my app case

@challengy1
Copy link

Sorry for my late reply. Unfortunately, I haven't tried it and I have no idea.

@kmsu
Copy link

kmsu commented Feb 2, 2024

Tuve el mismo problema. La solución que encontre fue usar este comando
npm install react-scripts@latest

verifiquen en las dependencias en el archivo package.json deben tener "react-scripts": "^5.0.1"
como versión. El comando que les puse es para actualizar esa dependencia.

PD. Disculpen por colocar la solución en estas fechas. Hasta ahora tuve el problemay encontré la solución

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests