googleapis导入因typescript / vue / firebase托管而失败

时间:2018-11-16 20:11:36

标签: typescript vue.js google-api firebase-hosting

在单个文件vue组件中,通过googleapis导入require失败,并显示错误:

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已导入

const { google } = require('googleapis')

如果是通过

导入的
import { google } from 'googleapis'

然后,第一次调用此google导入会出现相同的错误

帮助表示感谢:)

1 个答案:

答案 0 :(得分:0)

npm google api在浏览器中不起作用,因此我将其移至firebase函数中。