Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught type error when trying to install keycloak-js with vue and webpack: __WEBPACK_IMPORTED_MODULE_3_keycloak_js__ is not a function

I am trying to install keycloak-js in my vue project as described in this tutorial and when I start my application I keep getting the error

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_keycloak_js__ is not a function

These are my entries in package.json

"keycloak-js": "^7.0.0",
"vue": "^2.5.2",
"webpack": "^3.6.0",

Like in the tutorial I import it with import * as Keycloak from 'keycloak-js' and start it with let keycloak = Keycloak(initOptions) which is the line that throws the error.

I also tried to require keycloak and then it just said Keycloak is not a function.

Could this error be webpack-related? This is imho the only difference between the tutorial and my application. I haven't found anyone else having the same problem.

like image 625
J. Unkrass Avatar asked Oct 25 '25 05:10

J. Unkrass


2 Answers

A co-worker just told me to try an older version of Keycloak and now it works.

"keycloak-js": "^6.0.1",
like image 107
J. Unkrass Avatar answered Oct 27 '25 21:10

J. Unkrass


This is supposedly a bug in keycloak.js version 7.0.0 itself and as far as I know will be patched very soon. Until then I would stick to the latest 6.* version, which is 6.0.1

like image 39
Jörn Brett Avatar answered Oct 27 '25 21:10

Jörn Brett