-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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" error in common/classes.js #3739
Comments
What build system are you using? How are you getting Blueprint on the page? |
I'm using https://nx.dev/web. I think their build system wraps Webpack. |
Webpack runs in Node, so |
@adidahiya This error is occuring in the browser, not in Node. Webpack is a "bundler", e.g. it runs in Node, but it creates a combined JS file to be executed in the browser. That bundle includes the compiled result of If you try to reference a Node API from code running in the browser, it will not work, unless your build tool (such as Webpack) has specially inserted the relevant symbols. However, you cannot assume that it will do this. Some build setups will do so, but many others won't. For example, you might not be using a bundler at all, and might be importing the ESM module directly using <script type="module"> syntax. |
I was able to fix it by adding following to webpack config
|
hmr will not work when i set |
This comment has been minimized.
This comment has been minimized.
This was driving me nuts all day, I had to use this instead of the above in order for my electron application to build at all: plugins: [
new webpack.DefinePlugin({
'process.env': `(${JSON.stringify(process.env)})`
})
] |
I ran into this trying to use esbuild to build BlueprintJS. Explicitly defining I added the following before importing my bundle, which got me past the problem.
But this seems like something that should be cleaned up. Interestingly, it looks like elsewhere in the blueprint source it checks for the existence of
But if I don't explicitly define
with the error:
|
Thanks, that was fast. you are awesome @adidahiya . |
Environment
If possible, link to a minimal repro (fork this code sandbox):
Steps to reproduce
process
.Actual behavior
Expected behavior
It should not error.
Possible solution
https://github.com/palantir/blueprint/blob/develop/packages/core/src/common/classes.ts#L22
process
is a node API. It might exist in the browser if the build system happens to have defined it, but you should not just blindly assume it will be there!The text was updated successfully, but these errors were encountered: