Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process is not defined for KV use on Vite when using either fix in documentation #743

Open
mfzha opened this issue Aug 29, 2024 · 0 comments

Comments

@mfzha
Copy link

mfzha commented Aug 29, 2024

The main issue is that the moment a line like

import { createClient } from '@vercel/kv;

is added (and before use), there is an error

 Uncaught ReferenceError: process is not defined

This is despite trying either fix in the documentation, for instance

// vite.config.js
import dotenvExpand from 'dotenv-expand';
import { loadEnv, defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  if (mode === 'development') {
    const env = loadEnv(mode, process.cwd(), '');
    dotenvExpand.expand({ parsed: env });
  } 
  return { plugins: [react()], };
});

will still give the same process is not defined error. The same goes when importing credentials from a file.

I'm using the following versions, with dev script vite.

vite: ^5.4.1
@vercel/kv: ^2.0.0
react: ^18.3.1
node: 20.12.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant