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

i get error after i build ReferenceError: process is not defined #21

Closed
melsayedgit opened this issue Jun 17, 2023 · 5 comments
Closed
Labels
missing reproduction This issue does not provide a reproducible example of the problem.

Comments

@melsayedgit
Copy link

melsayedgit commented Jun 17, 2023

ReferenceError: process is not defined

@melsayedgit melsayedgit changed the title while building an react with vite - JavaScript heap out of memory while building a react with vite - JavaScript heap out of memory Jun 17, 2023
@melsayedgit melsayedgit changed the title while building a react with vite - JavaScript heap out of memory i get error after i build ReferenceError: process is not defined Jun 17, 2023
@davidmyersdev
Copy link
Owner

Hey there. 👋 Can you share your Vite config or provide a reproduction for me?

@isirode
Copy link

isirode commented Jun 18, 2023

Hello, I've encountered the same/similar error.

My config was the default one, but I've tried to play with the globals properties (disabling process and global) since I only needed to polyfill 'path'.

It did not worked either way.

import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    nodePolyfills({
      // To exclude specific polyfills, add them to this list.
      exclude: [
        'fs', // Excludes the polyfill for `fs` and `node:fs`.
      ],
      // Whether to polyfill specific globals.
      globals: {
        Buffer: true, // can also be 'build', 'dev', or false
        global: true,
        process: true,
      },
      // Whether to polyfill `node:` protocol imports.
      protocolImports: true,
    }),
  ],
})

My error was slighly different, it was 'Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')', from this code (from jest-util):

var _default =
  !!process.stdout.isTTY && process.env.TERM !== 'dumb' && !_ciInfo().isCI;
exports.default = _default;

My context is specific, I am running Mocha tests using WebDriverIO browser runner (which use Vite).

I do not have this error when I am not using the plugin.

I ended up using path-browserify manually, as an alias.

@davidmyersdev
Copy link
Owner

Hey @isirode. I still need a reproduction in order to debug this. If you can provide a StackBlitz or CodeSandbox example of this error, I should be able to diagnose the issue and get a fix out.

@davidmyersdev davidmyersdev added the missing reproduction This issue does not provide a reproducible example of the problem. label Jun 19, 2023
@isirode
Copy link

isirode commented Jul 19, 2023

Hi, sorry, I had forgotten about it since I did not used it in the end, I will try to provide a reproduction when I have time.

@davidmyersdev
Copy link
Owner

I'm closing this since I cannot reproduce it. Please open a new issue if this is still a problem.

@davidmyersdev davidmyersdev closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing reproduction This issue does not provide a reproducible example of the problem.
Projects
None yet
Development

No branches or pull requests

3 participants