keycloak-angular cannot find keycloak-js after install or upgrade
keycloak-angular is unable to find keycloak-jsShort answer
keycloak-js is a peer dependency of keycloak-angular, so installing keycloak-angular alone does not bring it. Install both packages together. If the build still complains, check that the keycloak-angular major matches your Angular major and that the keycloak-js version is in the supported range.
Fix it fast
1Find out which cause you have
List which of the two packages npm has installed in the project.
npm ls keycloak-angular keycloak-js2Match what you see, then jump to its fix
What does the error look like?
keycloak-angular is unable to find keycloak-js
Cause 1 of 2
keycloak-js was never installed
1Check
The README says keycloak-js is a peer dependency, which lets you choose the client version yourself. A peer dependency is not a replacement for your own entry in package.json.
grep -n "keycloak" package.json2Fix
Install both packages, as the README does.
npm install keycloak-angular keycloak-js3Verify
Both appear in the tree and the build runs.
npm ls keycloak-angular keycloak-js
npx ng buildConfirmed by github.com
Cause 2 of 2
keycloak-angular major does not match the Angular major
1Check
From Angular 19 on, keycloak-angular uses the same major number as Angular. The README table pairs Angular 21 with keycloak-angular 21 and keycloak-js 18 to 26.
npm ls @angular/core keycloak-angular keycloak-js2Fix
Install the keycloak-angular major that matches your Angular major, and a keycloak-js version inside the table's range.
npm install keycloak-angular@21 keycloak-js@263Verify
No peer dependency errors remain.
npm ls keycloak-angular keycloak-jsConfirmed by github.com
How do I stop it coming back?
- List keycloak-js yourself in package.json, never rely on it arriving by itself.
- When you run ng update, read the keycloak-angular compatibility table before the next step.
- Commit the lockfile so every machine resolves the same versions.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Back end
Airflow SSHOperator stops a long script with SSH command timed out
airflow.exceptions.AirflowException: SSH command timed out
SSHOperator waits only 10 seconds for a command by default.
3 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fix