node_modules/@types/node/globals.global.d.ts(1,44) 中的错误:错误 TS2304:找不到名称“globalThis”

vrr*_*234 4 typescript angular

我正在使用 angular 7.2.6、angular-cli 7.3.9 和 typescript 3.2.4。在 node_modules/@types/node/globals.global.d.ts(1,44) 中构建角度应用程序时出现错误:错误 TS2304:找不到名称“globalThis”。有人可以让我知道此错误的可能原因。

我看到 globalThis 是在 typescript 3.4 中引入的;但考虑到我使用的是 typescript 3.2.4,不确定是什么导致了上述问题,以及 globalThis 模块如何被引用访问变量。

vrr*_*234 8

感谢 Vishal Kedar 的回复。您的回答帮助我进一步思考和探索。在我更改 "@types/node": "10.14.0" 后,问题解决了。


小智 6

更新package.json以下模块的文件

"@types/node": "^14.0.4"
Run Code Online (Sandbox Code Playgroud)