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

ReferenceError: TextEncoder is not defined in axios >= 1.3.0 #5529

Closed
Shhad opened this issue Feb 3, 2023 · 8 comments · Fixed by #5530
Closed

ReferenceError: TextEncoder is not defined in axios >= 1.3.0 #5529

Shhad opened this issue Feb 3, 2023 · 8 comments · Fixed by #5530

Comments

@Shhad
Copy link

Shhad commented Feb 3, 2023

Describe the issue

Hi,
I've encountered problem after upgrading axios to version 1.3.0.
In my tests, below error has shown up:

ReferenceError: TextEncoder is not defined

at Object. (node_modules/axios/lib/helpers/formDataToStream.js:7:21)

I saw release notes but I didn't find any breaking changes.

Is it a bug?

In version 1.2.6 this error does not exist.

Example Code

No response

Expected behavior

No response

Axios Version

No response

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@DigitalBrainJS
Copy link
Collaborator

DigitalBrainJS commented Feb 3, 2023

You are probably using node.js older than v11.0.0 while we officially support v12 and above. Is this the only problem? Does Axios 1.2.x work on your platform?

@JanHamara
Copy link

Using Node v18.13.0 and having the same issue.

@DigitalBrainJS
Copy link
Collaborator

@JanHamara Just tested on 18.12.1

import axios from 'axios';

const form = new FormData();

form.append('foo', 'bar');

const {data} = await axios.post('http://httpbin.org/post', form);

console.log(process.version, axios.VERSION, data);
v18.12.1 1.3.0 {
  args: {},
  data: '',
  files: {},
  form: { foo: 'bar' },
  headers: {
    Accept: 'application/json, text/plain, */*',
    'Accept-Encoding': 'gzip, compress, deflate, br',
    'Content-Length': '155',
    'Content-Type': 'multipart/form-data; boundary=axios-1.3.0-boundary-6BBlTU-r5g8APj-bM4F1kQvaW',
    Host: 'httpbin.org',
    'User-Agent': 'axios/1.3.0',
    'X-Amzn-Trace-Id': 'Root=1-63dd3329-227877ef285aa1e81e1d49ce'
  },
  json: null,
  origin: '195.170.179.85',
  url: 'http://httpbin.org/post'
}

@rahulthedevil
Copy link

rahulthedevil commented Feb 3, 2023

v18.12.1
1.3.1 {
args: {},
data: '',
files: {},
form: { foo: 'bar' },
headers: {
Accept: 'application/json, text/plain, /',
'Accept-Encoding': 'gzip, compress, deflate, br',
'Content-Length': '155',
'Content-Type': 'multipart/form-data; boundary=axios-1.3.1-boundary-_BWIpm1l0Kgn5YVfdMQy6Rw8f',
Host: 'httpbin.org',
'User-Agent': 'axios/1.3.1',
'X-Amzn-Trace-Id': 'Root=1-63dd3572-36d82a1762ca21e200dda896'
},
json: null,
origin: '49.207.194.31',
url: 'http://httpbin.org/post'
}

Working fine in 1.3.1 also @JanHamara

@irfandyj
Copy link

Hi, I'm using axios 1.5.1 with node version v18.16.0 and still have the issue.

@irfandyj
Copy link

Guys, turns out it fails if you use yarn, I tried reinstalling with npm and it works.

@boldwade
Copy link

I have the same problem when using Vite version 5. Vite 4.5.3 works. 🤷‍♂️
I looked at patching the export, but... meh..

@dippas
Copy link

dippas commented Aug 14, 2024

this issue was introduce back in v1.7.0

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

Successfully merging a pull request may close this issue.

7 participants