Search code examples
typescriptvue.jsgoogle-apifirebase-hosting

googleapis import fail with typescript/vue/firebase hosting


In a single file vue component, importing googleapis via require fails with error:

Uncaught TypeError: Cannot convert undefined or null to object
at Function.getPrototypeOf (<anonymous>)
at t.exports (index.js:75)
at Object.f447 (index.js:54)
at o (bootstrap:78)
at Object.d465 (jwtclient.js:26)
at o (bootstrap:78)
at Object.<anonymous> (googleauth.js:37)
at Object.0a40 (googleauth.js:640)
at o (bootstrap:78)
at Object.3ccc (index.js:18)

googleapis has been imported with

const { google } = require('googleapis')

If it's imported with

import { google } from 'googleapis'

Then the same error will appear the first time this google import gets called

Help appreciated :)


Solution

  • npm google apis won't work in browser so I moved that part into firebase functions instead.