davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
301 stars 22 forks source link

TypeError: undefined is not an object (evaluating 'process.version.slice') #96

Closed IbrahimSam96 closed 3 months ago

IbrahimSam96 commented 3 months ago

Summary

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { nodePolyfills } from "vite-plugin-node-polyfills";

// https://vitejs.dev/config/
export default defineConfig(async () => ({
  plugins: [react(), nodePolyfills({})],
  // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  //
  // 1. prevent vite from obscuring rust errors
  clearScreen: false,
  // 2. tauri expects a fixed port, fail if that port is not available
  server: {
    port: 1420,
    strictPort: true,
    watch: {
      // 3. tell vite to ignore watching `src-tauri`
      ignored: ["**/src-tauri/**"],
    },
  },
  define: {
    "process.env": {},
  },
}));
IbrahimSam96 commented 3 months ago

// This was crashing things
define: { "process.env": {}, },