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
Imports error with CommonJS + Typescript #5008
Comments
I am experiencing the exact same problem. |
Probably related to #5000. |
Same issue as well. |
See #5030 merged should fix this. |
I'm also facing the same problem. |
I still have this issue with axios v1.1.3. TS import: import axios from 'axios'; JS code transpiled by tsc: const axios_1 = require('axios');
// ...
const { data } = await axios_1.default.get('http://example.com'); This throws the exception:
|
I solved this problem with this workaround: import { AxiosStatic } from "axios";
const Axios = require("axios") as AxiosStatic; |
squaresmile
added a commit
to atlasacademy/apps
that referenced
this issue
Dec 22, 2022
- tsc esm output has incomplete imports (missing ".js"). This can be resolved by adding ".js" (not ".ts") to the ts files' imports but that feels icky so it's probably best to stick with cjs. - axios@1 has broken exports axios/axios#5008 and feels overall unstable so it's probably best to stay at @0 for the foreseeable future.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using commonjs + typescript (in nest.js project, also reproduced standalone), imports are not consistent:
axios.default
To Reproduce
See https://github.com/ivanpepelko/axios-import-require-issue
Attached:
Expected behavior
axios.default
to be exported as per documentation.Environment
The text was updated successfully, but these errors were encountered: