nuxt: Vite SSR dev bundler transpile error by using firebase-admin sdk
Environment
- Operating System:
Darwin
- Node Version:
v16.13.0
- Nuxt Version:
3.0.0-rc.1
- Package Manager:
yarn@1.22.17
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
Use the firebase-admin sdk with latest version of nuxt rc1:
https://github.com/DevJoghurt/nuxt3-firebaseadmin
Describe the bug
This bug seems to be related to this fix:
https://github.com/nuxt/framework/pull/4371
Additional context
No response
Logs
[nuxt] [request error] Cannot read properties of undefined (reading 'SDK_VERSION')
at $id_9d001d45 (./.nuxt/dist/server/server.mjs:2616:51)
at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:3809:3)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 21 (8 by maintainers)
Same here
Here’s that specific line
firebase-admin
exports esm tooStarting with
nitropack@0.4.4
andunenv@0.5.2
, we are using a cross-version compatible ofnode-fetch
(unjs/node-fetch-native) that should resolve the issue when multiple versions ofnode-fetch
exist in a project.Please use
npx nuxi upgrade --force
to receive this update.However, I think there are more things attached to this issue so keeping it open.
Glad it works! Yes we are going to roll it out as default (aimed to be before the stable releases).
I have just done the following in my project:
experimental.viteNode = true
to nuxt config.npx nuxi upgrade --force
nitropack@0.4.4
andunenv@0.5.2
Unfortunatley I am seeing the same as @areindl - production builds (
nuxi build
) succeeds but dev (nuxi dev
) results in the error:Interestingly, this “Warning” appears only when I try to hit the local HTTP server in my browser. Dev server appears to build as normal, but errors when trying to hit it.
@DevJoghurt @antfu - I tried to build the project and now there is a new issue:
Ran the build using npm run build - no errors.
Then trying to run the app:
Not sure if this is a NUXT or Firebase issue.
But node-fetch is actually using type:“module”: https://github.com/node-fetch/node-fetch/blob/043a5fcfc82884155bcb2afba2a82333b2f29c02/package.json#L7
I can also confirm that it works 👌
Thanks @antfu!
It worked ✅. Firebase Auth is now loading as expected.
Here is my reproduction repo: https://github.com/areindl/nuxt3-firebase-auth-starter
Will this be a default in the future?
I guess we can close it then.
Could you try enabling
vite-node
byAnd see if it fixes the issue? Thanks.