Uncaught ReferenceError: process is not defined #369
-
"peerDependencies": {
"graphql": ">=0.11 <=16"
},
"devDependencies": {
"graphql": "^16.5.0"
} The process.env.NODE_ENV === 'production' This variable doesn't seem to be initialized by all bundlers (webpack specific?). Is it possible to make this library only an optional dependency to Note that I have been looking for solutions to avoid the error, but there is no real clean solution available according to my searches. Note also that a bunch of people encounter this annoying error (by googling "Uncaught ReferenceError: process is not defined") because of third-party libraries depending on libraries making use of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Furthermore, seems like this has already been fixed with graphql/graphql-js#3501, but not released as of now. Until it gets released, I'd go with appending the recommended polyfil in your <script>
window.process = globalThis.process = {
env: {
NODE_ENV: "development" // or "production", depending on your environment
}
};
</script> or by making your bundler replace all instances of |
Beta Was this translation helpful? Give feedback.
-
I personally use I had a quick look into the code and I do not see any use of the |
Beta Was this translation helpful? Give feedback.
graphql
is a peer dependency ofgraphql-ws
, it is necessary for proper functioning of the library and therefore cannot be optional.Furthermore, seems like this has already been fixed with graphql/graphql-js#3501, but not released as of now.
Until it gets released, I'd go with appending the recommended polyfil in your
index.html
:or by making your bundler replace all instances of
process.env.NODE_ENV === 'production'
withtrue/false
.