Search code examples
jwttypeerrortsconfigangular16

TypeError: invalid 'instanceof' operand KeyObject


When I try to log in to the system where I have defined the username and password, I get the error "TypeError: invalid 'instanceof' operand KeyObject". I edited angular.js and other contents, but I have not been able to fully solve the problem.
I am using the following versions:

Angular CLI: 16.2.2 Node: 18.18.0 Package Manager: npm 9.8.1 OS: win32 x64enter code here Angular: 16.2.8 ... animations, common, compiler, compiler-cli, core, forms ... localize, platform-browser, platform-browser-dynamic ... platform-server, router @angular-devkit/architect 0.1602.6 @angular-devkit/build-angular 16.2.6 @angular-devkit/core 16.2.2 @angular-devkit/schematics 16.2.6 @angular/cdk 16.2.7 @angular/cli 16.2.2 @angular/fire 7.6.1 @angular/material 16.2.7 @angular/material-moment-adapter 16.2 @ngtools/webpack 16.2.6 @nguniversal/builders 16.2.0 @nguniversal/express-engine @schematics/angular 16.2.0 rxjs 7.8.1 typescript 5.1.6 webpack 5.88.2 zone.js 0.13.3

I can get a solution suggestion for " ERROR TypeError: invalid 'instanceof' operand KeyObject ".


Solution

  • Pay attention to compatible package installations for Angular 16! To solve my own problem, you should install "npm i browser-crypto" as an additional package compatible with version 8.5.1 of jsonwebtoken 9.0.2 software. Also, the content of the tsconfig.json file: "browser": {"crypto": true,} and "paths": {"crypto": ["node_modules/crypto-browserify"] You should update it as .