在我们的 Angular 18 应用程序中,我们从 Keycloak 版本 25 切换到 26。package.json 中的库版本组合运行良好:
{
...
"keycloak-angular": "^16.0.1",
"keycloak-js": "^25.0.1",
...
}
现在我们尝试切换到 keycloak-js 版本 26:
{
...
"keycloak-angular": "^16.1.0",
"keycloak-js": "^26.0.5",
...
}
问题是为什么 keycloak-js 无法在 keycloak-Angular 之前工作过的情况下找到它。这是 tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": ["ES2022", "dom"],
"paths": {
"@core/*": ["./src/app/core/*"],
"@shared/*": ["./src/app/shared/*"]
},
"resolveJsonModule": true, // Enable JSON imports (needed to import package.json in e.g. app/core/services/version.service.ts)
"allowSyntheticDefaultImports": true // Allow default imports from modules with no default export (needed to import package.json in e.g. app/core/services/version.service.ts)
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
对于字段 moduleResolution 我尝试了“bundler”而不是“node”,但这会引发另一个错误:
如果我将 moduleResolution 重置回 Node,并将 keycloak-js 重置回 25.0.1,一切都会再次正常。有什么想法吗?
更改配置或依赖项后,清除 npm 缓存并重新安装所有内容始终是个好主意:
rm -rf 节点模块 rm package-lock.json npm 安装