Skip to content

Axios cannot be used #32729

@ys928

Description

@ys928

Environment


  • Operating System: Windows_NT
  • Node Version: v22.17.0
  • Nuxt Version: 4.0.1
  • CLI Version: 3.26.4
  • Nitro Version: 2.12.4
  • Package Manager: yarn@1.22.22
  • Builder: -
  • User Config: compatibilityDate, devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

I think this is very easy to reproduce:

  1. Create a new nuxt project
  2. Add Axios dependency
  3. Use Axios to send network requests

Describe the bug

using the Axios library to send network requests will result in an error

<script lang="ts" setup>
import axios from 'axios';
onMounted(() => {
  axios.get('http://localhost:3000')
})
</script>
500
Cannot read properties of undefined (reading 'FormData')

[Customize this page](https://nuxt.com/docs/getting-started/error-handling?utm_source=nuxt-error-dev-page)
Cannot read properties of undefined (reading 'FormData') at D:/desktop/node/test/node_modules/form-data/lib/browser.js:2:70) at ViteNodeRunner.runModule (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:397:10) at ViteNodeRunner.directRequest (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:375:14) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async ViteNodeRunner.cachedRequest (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:189:11) at async ViteNodeRunner.dependencyRequest (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:239:10) at async D:/desktop/node/test/node_modules/axios/lib/platform/node/classes/FormData.js:2:31) at async ViteNodeRunner.runModule (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:397:4) at async ViteNodeRunner.directRequest (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:375:3) at async ViteNodeRunner.cachedRequest (D:/desktop/node/test/node_modules/vite-node/dist/client.mjs:189:11)

Additional context

No response

Logs

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions