You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vite+Vue+TS环境创建PredictionServiceClient实例报错求助

问题:Vite+Vue+TS环境下创建PredictionServiceClient实例报错

在Vite + Vue + TypeScript环境中尝试使用Gemini Pro,创建PredictionServiceClient实例时触发错误,错误信息为Uncaught TypeError: Class extends value undefined is not a constructor or null。推测是循环引用导致,但找不到具体原因,求解决思路。

相关代码

import * as aiplatform from '@google-cloud/aiplatform';

const { PredictionServiceClient } = aiplatform.v1beta1;
const { helpers } = aiplatform;
const clientOptions = {
  credentials: {
    client_email: import.meta.env.VUE_APP_CLIENT_EMAIL,
    private_key: import.meta.env.VUE_APP_PRIVATE_KEY,
  },
  apiEndpoint: import.meta.env.VUE_APP_API_ENDPOINT,
};

const client = new PredictionServiceClient(clientOptions);

错误栈信息

Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/agent-base/dist/index.js (index.ts:29:42)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/https-proxy-agent/dist/index.js (index.ts:7:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gaxios/build/src/gaxios.js (gaxios.ts:33:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gaxios/build/src/index.js (index.ts:15:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gcp-metadata/build/src/index.js (index.ts:8:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)

更新说明

未能解决该错误,因需求是使用Gemini Pro,改用Gemini API后在相同环境下可正常运行,参考官方Gemini Pro快速入门内容完成切换。

内容的提问来源于stack exchange,提问作者Daisuke Takamizawa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 07:15:06