question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to use Axios 0.27.0 with React

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
TheSegcommented, Apr 26, 2022

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

10reactions
skelawskycommented, Apr 25, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to import Axios 1.x.x in ReactJS, Uncaught SyntaxError
I'm just trying to use axios in my React app. I can revert to 0.x.x, or I can try using fetch instead. But...
Read more >
axios bad request | The AI Search Engine You Control
Edit: axios errors come in three types: message , request and response . To make sure you are handling all possible errors, you...
Read more >
react-axios - npm
Supports custom axios instances through props or a <AxiosProvider ... > Create your own request components wrapped using the withAxios({options})( ...
Read more >
axios | Yarn - Package Manager
message); } console.log(error.config); });. Using the validateStatus config option, you can override the default condition (status >= 200 && status < 300) and ......
Read more >
Why You Need an API Layer and How To Build It in React
This is made possible by the Promise technology. Consequently, you need a Promise -based HTTP client like axios to implement an API layer....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found