Open Tcharlyson opened 2 years ago
In the provided example for me its just infinite loop into plugin with printing console.log from it. Its caused by defu error, but for some reason that error in plugin cause infinite loop ( possible another issue?). To get defu error need wrap axios.create from plugin into try catch e.g. like this
// eslint-disable-next-line import/named
import { NuxtAxiosInstance } from '@nuxtjs/axios'
import { Inject } from '@nuxt/types/app'
import type { Plugin } from '@nuxt/types'
export default <Plugin>function ({ $axios }, inject: Inject) {
console.log('Plugin is called')
// Create a custom axios instance
try {
const api = $axios.create({
headers: {
common: {
Accept: 'application/json'
}
}
}) as NuxtAxiosInstance
} catch (e) {
console.log(e)
}
}
which will produce following error:
Plugin is called
TypeError: external_defu_default(...) is not a function
at Function.create (file:///d:/sss/.output/server/chunks/server.mjs:16425:60)
at api (file:///d:/sss/.output/server/chunks/server.mjs:16542:30)
at createApp (file:///d:/sss/.output/server/chunks/server.mjs:16734:16)
at async __webpack_exports__.default (file:///d:/sss/.output/server/chunks/server.mjs:16829:12)
at async Object.renderToString (file:///d:/sss/.output/server/chunks/renderer.mjs:274:19)
at async file:///d:/sss/.output/server/chunks/renderer.mjs:658:20
at async file:///d:/sss/.output/server/node_modules/h3/dist/index.mjs:438:19
at async Server.nodeHandler (file:///d:/sss/.output/server/node_modules/h3/dist/index.mjs:384:7)
I have the same problem
npm i --save-dev defu@5.0.1
solves this problem
insatlling defu doesn't solve the problem on
------------------------------
- Operating System: `Linux`
- Node Version: `v16.19.0`
- Nuxt Version: `2.16.2`
- Nitro Version: `1.0.0`
- Package Manager: `yarn@1.22.19`
- Builder: `webpack`
- User Config: `bridge`, `target`, `nitro`, `components`, `runtimeConfig`, `app`, `css`, `loading`, `plugins`, `devServerHandlers`, `modules`, `build`, `router`, `twicpics`, `i18n`, `toast`, `sentry`, `content`, `serverHandlers`, `devServer`, `typescript`, `buildModules`
- Runtime Modules: `@nuxtjs/sentry@6.0.3`, `@nuxtjs/axios@5.13.6`, `@nuxtjs/i18n@7.3.1`, `@nuxtjs/toast@3.3.1`, `@twicpics/components/nuxt2@0.15.1`
- Build Modules: `()`, `@nuxt/bridge@3.0.0-27928371.c30fa0f`
------------------------------
confirmed, for the latest build @nuxt/bridge downgrade for defu - not working :((
im finded solution https://github.com/unjs/defu/issues/81#issuecomment-1458367904
Environment
Darwin
v14.19.3
2.16.0-27616340.013f051b
yarn@1.22.18
webpack
head
,ssr
,css
,plugins
,components
,buildModules
,modules
,axios
,dayjs
,vuetify
,publicRuntimeConfig
,privateRuntimeConfig
,storybook
,i18n
,build
,router
,serverHandlers
,devServerHandlers
,bridge
@nuxtjs/axios@5.13.6
,8n
,@nuxtjs/dayjs@1.4.1
Build Modules:
()
,@nuxtjs/stylelint-module@4.1.0
,@nuxtjs/vuetify@1.12.3
,@pinia/nuxt@0.1.9
,@nuxt/bridge@3.0.0-27657000.c87fdbe
Reproduction
https://codesandbox.io/s/confident-wildflower-cjzhey
Describe the bug
I've set a plugin :
On dev mode everything's fine but when I build and start, I got this error :
Line 22020 is :
Additional context
No response
Logs
No response