简体   繁体   English

在 Vite 项目中使用 Big Query

[英]Using Big Query in Vite Project

I would like to use Googles Big Query client to query a Big Query DB from a Vite app.我想使用 Google 的 Big Query 客户端从 Vite 应用程序查询 Big Query DB。 Following the provided documentation says to import BigQuery with the following statement:按照提供的文档说明使用以下语句导入 BigQuery:

const {BigQuery} = require('@google-cloud/bigquery');

Running this in App.tsx gives Uncaught ReferenceError: require is not defined在 App.tsx 中运行它会给出Uncaught ReferenceError: require is not defined

I tried switching to我试着切换到

import {BigQuery} from "@google-cloud/bigquery"

But then when I run the next line of code const bigqueryClient = new BigQuery();但是当我运行下一行代码时const bigqueryClient = new BigQuery(); I get the following error:我收到以下错误:

Uncaught ReferenceError: process is not defined
    at loadProxy (gaxios.ts:65:9)
    at node_modules/gaxios/build/src/gaxios.js (gaxios.ts:75:1)
    at __require2 (chunk-OROXOI2D.js?v=60dbfa40:16:50)
    at node_modules/gaxios/build/src/index.js (index.ts:15:1)
    at __require2 (chunk-OROXOI2D.js?v=60dbfa40:16:50)
    at node_modules/gcp-metadata/build/src/index.js (index.ts:8:1)
    at __require2 (chunk-OROXOI2D.js?v=60dbfa40:16:50)
    at node_modules/google-auth-library/build/src/auth/googleauth.js (googleauth.js:19:21)
    at __require2 (chunk-OROXOI2D.js?v=60dbfa40:16:50)
    at node_modules/google-auth-library/build/src/index.js (index.js:17:22)

How should I use the big query client in a vite app? vite应用中的大查询客户端应该如何使用? Is it possible?是否可以?

thank you!谢谢你!

define in vite.config.ts?在 vite.config.ts 中定义?

import { defineConfig } from "vite";
import solidPlugin from "vite-plugin-solid";

export default defineConfig({
  plugins: [solidPlugin()],
  server: {
    port: 3000,
  },
  build: {
    target: "esnext",
  },
  define: {
    global: {},
    process: {},
  },
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM