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

[TextField] "ReferenceError: process is not defined" #1486

Closed
alex-zuy opened this issue Aug 23, 2015 · 5 comments
Closed

[TextField] "ReferenceError: process is not defined" #1486

alex-zuy opened this issue Aug 23, 2015 · 5 comments
Labels
bug 🐛 Something doesn't work v0.x

Comments

@alex-zuy
Copy link

When TextField component is used in browser environment, calling method 'setErrorText' causes "ReferenceError: process is not defined". In the sources of material-ui this method implemented this way:
link to source

 setErrorText(newErrorText) {
    if (process.env.NODE_ENV !== 'production' && this.props.hasOwnProperty('errorText')) {
      ...
    }
    ...
  },

It figures out that 'process' is global variable which is defined in Node.js environment, but obviously absent in browser. Implementation must first check that 'process' variable is set, but it does not. I looked through another sources and found many cases like this.
The problem can be solved by manually defined dummy 'process' variable, but IMHO this must be fixed in library.
Hack to workaround this problem:

window.process = {env:{NODE_ENV:''}};
@zliang-min
Copy link

TextField is not the only component which has this issue. I just found FloatingActionButton also has the same issue.

@alitaheri
Copy link
Member

Well... this project was designed from ground up to be bundled. All these checks must follow the rule: process && process.env && process.env.NODE_ENV === "production" ... but they don't 😄 . Since all bundlers replace process.env.NODE_ENV with their bundle-time value this will not be an issue. However, if you try to include this without bundling, you'll bump into that ugly error. bundle the whole thing with browserify or webpack and you're good to go. :D

@alitaheri alitaheri added bug 🐛 Something doesn't work Deployment labels Dec 8, 2015
@oliviertassinari
Copy link
Member

The usage of process.env.NODE_ENV is intentional. That's simpler when working in an isomorphic environment (with node and the browser).
You would face the same issue by using react from npm. Hence I'm assuming you are using react from a CDN. I would refer to this issue then #262.

@Yamboy1
Copy link

Yamboy1 commented Aug 7, 2020

Is there any chance of this being fixed in the future? There are now alternatives to react that work fully in the browser such as preact, and it would be really nice to use material-ui with preact

@oliviertassinari
Copy link
Member

@Yamboy1 We have a best effort to support preact. If you can reproduce the issue with the latest version v5.0.0-alpha.5, please open a new issue. A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
Bumps [wait-on](https://github.com/jeffbski/wait-on) from 3.3.0 to 4.0.0.
- [Release notes](https://github.com/jeffbski/wait-on/releases)
- [Commits](jeffbski/wait-on@v3.3.0...v4.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work v0.x
Projects
None yet
Development

No branches or pull requests

5 participants