Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

keycloak-angular cannot find keycloak-js after install or upgrade

Errorkeycloak-angular is unable to find keycloak-js

Short 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.

  • Applies to Angular 21, keycloak-angular 21, keycloak-js 26, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List which of the two packages npm has installed in the project.

    npm ls keycloak-angular keycloak-js
  2. 2Match what you see, then jump to its fix

    1. 1npm ls shows keycloak-angular but keycloak-js is missing or marked invalidkeycloak-js was never installedFix
    2. 2Peer dependency warnings after an Angular upgradekeycloak-angular major does not match the Angular majorFix

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.json

2Fix

Install both packages, as the README does.

npm install keycloak-angular keycloak-js

3Verify

Both appear in the tree and the build runs.

npm ls keycloak-angular keycloak-js
npx ng build

Confirmed by github.com

Did this fix it?

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-js

2Fix

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@26

3Verify

No peer dependency errors remain.

npm ls keycloak-angular keycloak-js

Confirmed by github.com

Did this fix it?

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

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 fix

Back 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.