我在尝试创建 Nuxt 3 应用程序时收到此错误。我还没有使用 Axios 做任何事情,除了样板代码之外,该应用程序基本上是空的。
(base) app % npx nuxi build
Nuxi 3.0.0 14:32:27
Nuxt 3.0.0 with Nitro 1.0.0 14:32:27
ERROR Cannot read properties of undefined (reading 'options') 14:32:28
at axiosModule (node_modules/@nuxtjs/axios/lib/module.js:12:13)
at installModule (node_modules/@nuxt/kit/dist/index.mjs:416:9)
at async initNuxt (node_modules/nuxt/dist/index.mjs:1825:7)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:1857:5)
at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:34:18)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
axios 模块不再用于 Nuxt3,如下所述:https://stackoverflow.com/a/74679190/8816585
直接使用
$fetch
,它基本上是 ofetch 的包装。
查看模块是否与特定版本的 Nuxt 兼容的一种快速方法是使用模块页面,例如这里是 for axios。
正如你所看到的,它与 Nuxt3 不兼容,因为页面是空的。