【发布时间】: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