Auth0 节点包无法工作,除非我将“DOM”添加到 tsconfig 中的“lib”数组中。为什么我需要为纯粹的后端服务这样做?

问题描述 投票:0回答:1

我有一个nodejs后端服务,我想使用auth0管理API来做一些事情,比如手动创建用户。

不幸的是,除非我将

"DOM"
添加到我的 tsconfig.json 中,否则该库无法工作。

否则,我会收到以下错误:


node_modules/auth0/dist/cjs/auth/base-auth-api.d.ts(19,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/auth/base-auth-api.d.ts(21,102): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/auth/base-auth-api.d.ts(39,258): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/auth/base-auth-api.d.ts(39,305): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/errors.d.ts(7,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/errors.d.ts(9,60): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(5,36): error TS2304: Cannot find name 'RequestInfo'.
node_modules/auth0/dist/cjs/lib/models.d.ts(5,56): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(5,80): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(15,28): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(55,30): error TS2304: Cannot find name 'FormData'.
node_modules/auth0/dist/cjs/lib/models.d.ts(59,19): error TS2304: Cannot find name 'RequestCredentials'.
node_modules/auth0/dist/cjs/lib/models.d.ts(65,15): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(66,28): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(69,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(75,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(78,35): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(79,43): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(82,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(86,26): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(87,30): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(91,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(94,40): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/lib/models.d.ts(95,30): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(98,16): error TS2304: Cannot find name 'RequestInfo'.
node_modules/auth0/dist/cjs/lib/models.d.ts(99,11): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(103,16): error TS2304: Cannot find name 'RequestInfo'.
node_modules/auth0/dist/cjs/lib/models.d.ts(104,11): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(108,16): error TS2304: Cannot find name 'RequestInfo'.
node_modules/auth0/dist/cjs/lib/models.d.ts(109,11): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(110,15): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(114,16): error TS2304: Cannot find name 'RequestInfo'.
node_modules/auth0/dist/cjs/lib/models.d.ts(115,11): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/models.d.ts(117,16): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(121,46): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(121,65): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(122,46): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/models.d.ts(122,65): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/retry.d.ts(26,53): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/retry.d.ts(26,120): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/lib/runtime.d.ts(14,61): error TS2304: Cannot find name 'RequestInit'.
node_modules/auth0/dist/cjs/lib/runtime.d.ts(14,106): error TS2304: Cannot find name 'Response'.
node_modules/auth0/dist/cjs/management/management-client.d.ts(8,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/management/management-client.d.ts(11,94): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/userinfo/index.d.ts(34,14): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/userinfo/index.d.ts(36,102): error TS2304: Cannot find name 'Headers'.
node_modules/auth0/dist/cjs/userinfo/index.d.ts(38,46): error TS2304: Cannot find name 'Response'.

有什么方法可以避免将 DOM 添加到我的 tsconfig 中吗?

node.js typescript auth0
1个回答
0
投票

不幸的是,

auth0
包依赖于
Response
接口,该接口在
dom
库中定义。

您必须将

dom
添加到 lib 数组,或者在
skipLibCheck: true
中指定
compilerOptions
。根据 TypeScript 文档

TypeScript 不会对所有 d.ts 文件进行全面检查,而是会输入 检查您在应用程序源代码中特别引用的代码。

检查此答案,了解有关使用

skipLibCheck
的优点/缺点的更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.