You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problems with running keycloak-js in backend
#8543
root@743f5de4a1cf:/app# node packages/backend
/app/packages/backend/dist/index.cjs.js:25043
})(window, function (sha256_imported, base64js_imported) {
^
ReferenceError: window is not defined
at /app/packages/backend/dist/index.cjs.js:25043:4
at createCommonjsModule (/app/packages/backend/dist/index.cjs.js:90:9)
at Object.<anonymous> (/app/packages/backend/dist/index.cjs.js:25036:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
The keycloak-admin package has been deprecated and replaced with @keycloak/keycloak-admin-client. Could you install this dependency instead and report back if the same issue occurs?
Thanks for checking. Under normal circumstances keycloak-js should never be included in the actual Admin Client if on Node, this should happen only in the browser.
I think that you might be using some kind of bundler which is transforming this code so that it is always included. If that is the case I would refer to the documentation of that specific tool to prevent this from happening.
I tightened the check for a browser environment in the 'next' version, perhaps you can try installing that to see if the result is still the same?
Then I think this is really a problem with whatever bundler is being used to build your application together. I'd recommend looking there to see if the problem can be resolved.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I am using keycloak-admin (https://www.npmjs.com/package/keycloak-admin). And when I try to build & run my backend I get an error (in the runtime):
This is caused by usage of window variable here:
keycloak/adapters/oidc/js/src/main/resources/keycloak.js
Line 63 in 443bd4a
If window is substituted with {} or commonjsGlobal defined like this:
the process starts correctly.
All reactions
Replies: 2 comments · 4 replies
Uh oh!
There was an error while loading. Please reload this page.
@jonkoops FIY
All reactions
Uh oh!
There was an error while loading. Please reload this page.
The
keycloak-adminpackage has been deprecated and replaced with@keycloak/keycloak-admin-client. Could you install this dependency instead and report back if the same issue occurs?All reactions
Uh oh!
There was an error while loading. Please reload this page.
You are right. I pointed wrong package. I am using:
"@keycloak/keycloak-admin-client": "^15.0.2"So the whole issue is still valid.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Thanks for checking. Under normal circumstances
keycloak-jsshould never be included in the actual Admin Client if on Node, this should happen only in the browser.I think that you might be using some kind of bundler which is transforming this code so that it is always included. If that is the case I would refer to the documentation of that specific tool to prevent this from happening.
I tightened the check for a browser environment in the 'next' version, perhaps you can try installing that to see if the result is still the same?
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Sorry to say, but this dev version still generates such error.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Then I think this is really a problem with whatever bundler is being used to build your application together. I'd recommend looking there to see if the problem can be resolved.
All reactions