【问题标题】:googleapis import fail with typescript/vue/firebase hostinggoogleapis 导入失败,打字稿/vue/firebase 托管
【发布时间】:2018-11-16 20:11:36
【问题描述】:

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

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 import 会出现同样的错误

帮助表示赞赏:)

【问题讨论】:

  • 您是否尝试在浏览器中运行googleapis?那是行不通的。对于浏览器,您应该改用"JavaScript" client
  • @MattMcCutchen 谢谢!我最终将这部分功能移到 Firebase 函数中并从那里使用它:)

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


【解决方案1】:

npm google apis 在浏览器中不起作用,所以我将这部分移到了 firebase 函数中。

【讨论】:

    猜你喜欢
    • 2020-06-12
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 2020-06-17
    • 2018-06-07
    • 2021-05-08
    • 1970-01-01
    • 2021-01-20
    相关资源
    最近更新 更多