Skip to content

Uncaught ReferenceError: process is not defined #8189

Answered by snowystinger
cj3241 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure why they do it so differently and I still don't know how React manages to work with it in their source. But you don't need the replace module.

Instead, just add this to your vite.config.ts

  define: {
    'process.env': {}
  }

https://vite.dev/config/shared-options.html#define

You could change the keys in it depending on what you're doing. For instance you could use mode https://vite.dev/config/#conditional-config in here to set NODE_ENV to production or dev so that you get our new warning and error messages when you're developing but you don't need to worry about them in your production build.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@cj3241
Comment options

@snowystinger
Comment options

Comment options

You must be logged in to vote
2 replies
@snowystinger
Comment options

Answer selected by cj3241
@cj3241
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants