question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite SSR dev bundler transpile error by using firebase-admin sdk

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
wobsorianocommented, May 2, 2022

Same here

[nuxt] [request error] Cannot read properties of undefined (reading 'Auth')
  at $id_b788ed7e (./.nuxt/dist/server/server.mjs:3177:44)
  at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:4458:3)

Here’s that specific line

// --------------------
// Request: /node_modules/firebase-admin/lib/esm/auth/index.js
// Parents: 
// - /plugins/auth.server.ts ($id_0a045b03)
// Dependencies: 
// - /node_modules/firebase-admin/lib/auth/index.js ($id_d0eb9116)
// --------------------
const $id_b788ed7e = async function (global, module, exports, __vite_ssr_exports__, __vite_ssr_import_meta__, __vite_ssr_import__, __vite_ssr_dynamic_import__, __vite_ssr_exportAll__) {
const __vite_ssr_import_0__ = await __vite_ssr_import__("/node_modules/firebase-admin/lib/auth/index.js");


const Auth = __vite_ssr_import_0__.default.Auth;
Object.defineProperty(__vite_ssr_exports__, "Auth", { enumerable: true, configurable: true, get(){ return Auth }});

firebase-admin exports esm too

2reactions
pi0commented, May 11, 2022

Starting with nitropack@0.4.4 and unenv@0.5.2, we are using a cross-version compatible of node-fetch (unjs/node-fetch-native) that should resolve the issue when multiple versions of node-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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >
ts-node error [err_require_esm]: require() of es module
to use the import syntax and import node-fetch , but then you can't use require for any other packages. You need to work...
Read more >
vite-plugin-ssr
With vite -plugin-ssr , you integrate tools manually and keep architectural control. Learn more.
Read more >
How to configure vite/rollup to exclude firebase-admin from my ...
Basically I just want a clean setup with this simple stack: firebase functions; vite + SSR (using vite-plugin-ssr ); preact and typescript. > ......
Read more >
Vite in 100 Seconds - YouTube
Vite is a JavaScript build tool that makes it faster and easier to build web applications. It's similar to tools like Webpack, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found