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

CommonJS usage broken in v1.0.0 #5032

Closed
Niek opened this issue Oct 6, 2022 · 5 comments
Closed

CommonJS usage broken in v1.0.0 #5032

Niek opened this issue Oct 6, 2022 · 5 comments

Comments

@Niek
Copy link

Niek commented Oct 6, 2022

CommonJS usage seems to be broken in v1.0.0, the default export no longer exists (even though the README mentions it). Sample code:

$ echo "console.log(require('axios').default)" | node 
undefined
@jasonsaayman
Copy link
Member

Fixed in #5030 will release later today

@msageryd
Copy link

msageryd commented Oct 7, 2022

I've tried both 1.1.2 and 1.1.1, but require from node.js is not working. Do I need to do something special?

image

N.B. the "import" is not my code. Here is my code:

const axios = require('axios');

Edit: This is an old Docker container with Node 10. I'm not able to upgrade it right now. Is the old Node version a problem?

@jasonsaayman
Copy link
Member

I will look at this asap

@jasonsaayman jasonsaayman reopened this Oct 8, 2022
@DigitalBrainJS
Copy link
Collaborator

@msageryd Axios requires at least the latest minor versions of node v12. You can try importing the cjs package directly

const axios = require('axios/dist/node/axios.cjs'); // common js bundle

but there are no guarantees as some features require v12.

@jasonsaayman
Copy link
Member

Hi 👋

Please try the latest pre-release by running the following:

npm i axios@1.2.0-alpha.1

Please provide feedback in either the pinned issue or the discussion thread 🧵

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

4 participants