-
Notifications
You must be signed in to change notification settings - Fork 88
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
ReferenceError: window is not defined in NodeJS environment #585
Comments
Hi, this looks like an issue due to the protobuf library that we're using, see protocolbuffers/protobuf-javascript#8. There is a workaround mentioned in it, does that work for you? |
@shubham1172 thanks for the quick reply. I tried using this workaround but still encountered the issue. It is unfortunately also not workable for all our services since we use Sveltekit that can run on both server and client. Using this workaround broke the build for Sveltekit. |
In protocolbuffers/protobuf-javascript#8 (comment) the workaround is this: // @ts-ignore
globalThis.window = null;
// @ts-ignore
globalThis.self = null; @jhlabs, in case you haven't tried it already, how about something like this? 🤔 // @ts-ignore
if (typeof window === 'undefined') globalThis.window = null;
// @ts-ignore
if (typeof self === 'undefined') globalThis.self = null; That shouldn't interfere with Sveltekit |
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions. |
Expected Behavior
I expect to be able to launch the Dapr Javascript SDK in a NodeJS environment when running in a Docker container.
Actual Behavior
My different Typescript services that import the Dapr JS SDK launch just fine in my local environment. As soon as I try to run them packaged in a Docker Container I receive the following error on startup:
I don't have a great explanation for that. It seems that the Dapr SDK somehow thinks it is in a browser environment and therefore requires modules like window?
Steps to Reproduce the Problem
Package any application that uses the Dapr JS SDK in a Docker container and run the container.
The text was updated successfully, but these errors were encountered: