framework
framework copied to clipboard
Error: "defuFn is not a function" in 3.0.0-rc.9-xx
Environment
- Operating System:
MacOS
- Node Version:
v16.17.0
- Nuxt Version:
3.0.0-rc.9-27702110.abd5dc5
- Package Manager:
[email protected]
- Bundler:
Vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
package.json
"dependencies": {
"@headlessui/vue": "^1.6.7",
"@heroicons/vue": "^1.0.6",
"nuxt": "npm:nuxt3@^3.0.0-rc.9-27702110.abd5dc5",
"pinia": "^2.0.21",
"primeicons": "^5.0.0",
"primevue": "^3.15.0",
"vue": "^3.2.37"
}
Describe the bug
When trying to fix loading problem of resources (ex: js
files..) to follow cdnURL path with the version 3.0.0-rc.9-27702110.abd5dc5
, and the resources loading problem was solved perfectly, thank you!
But there was an error with:
__vite_ssr_import_0__.defuFn is not a function
Temp Solution:
I solved it with adding defu dependencies "defu": "^6.1.0"
in package.json
for now.
npm i defu
Has anyone run into the same problem? Or other solutions? Thank you!
Additional context
No response
Logs
No response
Would you please prodive a reproduction?
same here but installing defu
doesn't help
same here with [email protected] and @[email protected]
same here with [email protected] and @[email protected]
Instead of "same here", please provide a reproduction if the "needs reproduction" label is visible. Feel free to use the starter from https://nuxt.new/
I'm experiencing the same issue and trying to find the error to create a reproduction. But installing defu
for now solved the issue.
Same thing here. I understand you're asking for a reproduction, but it's a big project and evrything created from scratch would not reflect it. My project worked with rc8, and I have this error message with rc9 when doing npm run dev. Could you at least explain the meaning of the error message to do our own research if you don't want to help without reproduction ? Thanks
[nuxt] [request error] [unhandled] [500] __vite_ssr_import_0__.defuFn is not a function
at ./.nuxt/app.config.mjs:9:54
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/index.mjs:7:31
Kind of "good" news : after many tries on my project, I just launched a new empty project with nuxi init and the problem appears the same way ! @danielroe So is it something more hardware or os related ? @lucassimines on which Os are you ?
nuxi version : Nuxi 3.0.0-rc.9 node version v16.13.1 npm version 8.19.1 MacBook Air / Apple M1 / 8Go on Monterey 12.4
after rc.8 upgrade to rc.9 ,npm run dev vuex similar error occurred
after rc.8 upgrade to rc.9 ,npm run dev vuex similar error occurred
[nuxt] [request error] [unhandled] [500] __vite_ssr_import_0__.createStore is not a function
at C:/project/nuxt-test/website-mobile/store/index.ts:5:37
at async ViteNodeRunner.directRequest (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:113:12)
at async request (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:136:16)
at async C:/project/nuxt-test/website-mobile/pages/buyin.vue?macro=true:11:31
at async ViteNodeRunner.directRequest (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:113:12)
at async request (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:136:16)
at async virtual:nuxt:C:/project/nuxt-test/website-mobile/.nuxt/routes.mjs:1:238
at async ViteNodeRunner.directRequest (/C:/project/nuxt-test/website-mobile/node_modules/vite-node/dist/client.mjs:217:5)
Not theexact same error msg @Erica-lyj , different issue I'm afraid ?
Update : I confirm the problem only occurs on Mac. Same repo, same update made on my windows 10 computer, no error.
im creating brand new project with npx nuxi init <Project-name> and when i run npm run dev same problem happen. Im on mac
Same issue, Fedora Node v16.14.0
npm init vite my-project
-> Nuxt project
Barebone project fails
Nuxi 3.0.0-rc.9 20:42:04
Nuxt 3.0.0-rc.9 with Nitro 0.5.1 20:42:04
20:42:06
> Local: http://localhost:3000/
> Network: http://192.168.100.44:3000/
> Network: http://172.24.0.1:3000/
ℹ Vite client warmed up in 766ms 20:42:08
ℹ Vite server warmed up in 270ms 20:42:08
✔ Nitro built in 730 ms nitro 20:42:09
[nuxt] [request error] [unhandled] [500] __vite_ssr_import_0__.defuFn is not a function
at ./.nuxt/app.config.mjs:9:54
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/index.mjs:7:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
Update : I confirm the problem only occurs on Mac. Same repo, same update made on my windows 10 computer, no error.
The problem also exists on windows 11
Stuck for two days here. Rolled back to rc8, wished i rolled back to Nuxt 2 for my project...
I have also had the same error since today. I have just recreated the project and have not made any changes to the standard.
`$ nuxt dev -o
Nuxi 3.0.0-rc.9 16:38:57 Nuxt 3.0.0-rc.9 with Nitro 0.5.1 16:38:57 16:38:58
Local: http://localhost:3000/ Network: http://192.168.0.170:3000/
ℹ Vite client warmed up in 301ms 16:38:59
ℹ Vite server warmed up in 72ms 16:38:59
✔ Nitro built in 205 ms nitro 16:38:59
[nuxt] [request error] [unhandled] [500] vite_ssr_import_0.defuFn is not a function
at ./.nuxt/app.config.mjs:9:54
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/index.mjs:7:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
[nuxt] [request error] [unhandled] [500] vite_ssr_import_0.defuFn is not a function
at ./.nuxt/app.config.mjs:9:54
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async ./node_modules/nuxt/dist/app/index.mjs:7:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)`
Same issue, only removed the the node_modules folder and changed to "nuxt": "3.0.0-rc.8" in the package.json. And it works back again :)
Same issue.
On Mac (Intel),
Happened just after I made a npm -g upgrade, then created a brand new with npx nuxi init -t doc-driven ui. I'm using brew too, it caused issues in the past with npm global package (maybe a track).
Wow @gpicron what you wrote is a huge deal : I've uninstalled homebrew on my Mac, and now rc9 works and the defuFn error message is gone ! That's not a complete solution and doesn't explain what the problem was, but I take it.
I have same issue on a fresh Nuxt RC9. No extra packages just :
-
npx nuxi init nuxt-app
-
npm install
-
npm run dev
I tried yarn too
just write ssr: false in nuxt.config.ts
just write ssr: false in nuxt.config.ts
...Except if you want server side rendering 🙃
just write ssr: false in nuxt.config.ts
Doesnt fix it, just pushed the problem to the client: Here is what you get in the console of a web browser instead.
app.config.mjs:2 Uncaught SyntaxError: The requested module '/_nuxt/node_modules/.vite/deps/defu.js?v=5440456e' does not provide an export named 'defuFn' (at app.config.mjs:2:10)
I was able to track down the issue to not Nuxt specially but using including @nuxtjs/axios breaks it. Here is my repo to reproduce the issue:
https://github.com/joseph-montanez/nuxt-framework-issue-7168
npm i
npm run dev
Then go to http://localhost:3000/ and you'll get:
500
__vite_ssr_import_0__.defuFn is not a function
at ./.nuxt/app.config.mjs:9:54
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:251:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:128:12)
at async request (./node_modules/vite-node/dist/client.mjs:151:16)
at async ./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:251:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:128:12)
at async request (./node_modules/vite-node/dist/client.mjs:151:16)
at async ./node_modules/nuxt/dist/app/index.mjs:7:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:251:5)
Update: I've added a Docker instance:
docker compose up -d
Then go to http://localhost:3000/
So this isn't a MacOS issue, maybe something related to ArmV8?
It's kind of frustrating seeing it tagged need reproduction when the only commands I have run are
Operating system: Windows 10 x64
Node version: 16.14.2
npx nuxi init app
yarn install
yarn dev
and then you spend hours figuring out where you went wrong and find the issue that is 10 days old
i Vite server warmed up in 1127ms
i Vite client warmed up in 3697ms
√ Nitro built in 1747 ms
[nuxt] [request error] [unhandled] [500] __vite_ssr_import_0__.defuFn is not
a function
at./.nuxt/app.config.mjs:9:54
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async./node_modules/nuxt/dist/app/config.mjs:5:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:113:12)
at async request (./node_modules/vite-node/dist/client.mjs:136:16)
at async./node_modules/nuxt/dist/app/index.mjs:7:31
at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:217:5)
It's kind of frustrating seeing it tagged need reproduction when the only commands I have run are
You already showcased the problem quite well. The commands you have to run. Just because the issue pops up for you (and a hand full of people), it doesn't mean it is easy to reproduce 🙈 Actually it is quite the opposite.
I tried doing exactly what you wrote and do not receive any errors. 😅
Suggestions / Workarounds to try
Some ideas that could help:
- Ensure you don't have a Nuxt2-only module installed
- Install
defu
manually (e.g.yarn add defu
/npm i defu
) - Try out another package manager, e.g. pnpm with
pnpm i --shamefully-hoist
, thenpnpm dev
.
I solved the problem in my case just by doing one thing (even if that sounds weird) :
- Uninstall homebrew on my mac
- Upgrading nuxt
- Reinstalling homebrew (because i need it)
Just because the issue pops up for you (and a hand full of people), it doesn't mean it is easy to reproduce 🙈 Actually it is quite the opposite.
I've provided a Github Repo that produces the issue 100% of the time:
https://github.com/joseph-montanez/nuxt-framework-issue-7168
npm i npm run dev
Installing Nuxt on its own works fine, its when its combined with a library. I've tried this on my Linux, two Windows 10 and two Mac Mini's (Intel and M1). They all exhibit the same issue. I did add a docker instance but its not working at the moment.
Just because the issue pops up for you (and a hand full of people), it doesn't mean it is easy to reproduce 🙈 Actually it is quite the opposite.
I've provided a Github Repo that produces the issue 100% of the time:
joseph-montanez/nuxt-framework-issue-7168
npm i npm run dev
Installing Nuxt on its own works fine, its when its combined with a library. I've tried this on my Linux, two Windows 10 and two Mac Mini's (Intel and M1). They all exhibit the same issue. I did add a docker instance but its not working at the moment.
It can be reproduced that way 👏🏻
@joseph-montanez But why is @nuxtjs/axios
included? It is a Nuxt2 module 🤔
When removing it from package.json
and recreate lockfile, things work accordingly 👍🏻
@joseph-montanez But why is
@nuxtjs/axios
included? It is a Nuxt2 module 🤔When removing it from
package.json
and recreate lockfile, things work accordingly 👍🏻
I had the same issue. Nuxt 3 RC 10, I just removed @nuxtjs/axios and installed Defu. Now it works like a charm.