axios: import axios from 'axios' results in undefined
Describe the bug
In TypeScript file, when I do import axios from 'axios'
, the axios
variable is inferred as AxiosStatic
, however the value of it is undefined
;
This used to be working on axios version 0.x.x
To Reproduce
No response
Code snippet
No response
Expected behavior
No response
Axios Version
1.x.x
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
16.15.0
OS
OSX12.2.1 (M1 chip)
Additional Library Versions
No response
Additional context/Screenshots
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 15
- Comments: 17 (3 by maintainers)
try to enable
esModuleInterop
in tsconfig.I’m sorry - but how does such a major issue get introduced in a patch update? Aren’t there tests for this?
I went back to 1.1.0 and it solved the problem - but I definitely spent time troubleshooting what is wrong in my app and it was this… I just don’t understand how something as simple as importing the library got broken on such a small update.
Hey thanks for the fix! I tried the
1.2.0-alpha.1
but the new release makes the TS>JS transpiling fail (I usedgts
withnpx gts init
)Hi 👋
Please try the latest pre-release by running the following:
Please provide feedback in either the pinned issue or the discussion thread 🧵
I’m not sure this is a real solution? Something is clearly broken with the exports - we shouldn’t have to modify our tsconfig to fix the issue. All of my other dependencies work just fine with the existing tsconfig settings, and this module used to work just fine as well. Shouldn’t it be fixed in an update??
this works for me
const axios = require('axios')
But I had to change from axios.post to
response = await axios({ method: 'post', url: url, data: data, headers: headers, })
and no autocomplete or other TS goodies.