在 angular 7 中找不到名称“要求"(打字稿 3.1.3)

编程入门 行业动态 更新时间:2024-10-10 14:30:35
本文介绍了在 angular 7 中找不到名称“要求"(打字稿 3.1.3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的问题是为什么会显示此错误?

My question is why this error shown?

src/app/p2p/p2pponent.ts(14,16) 中的错误:错误 TS2580:不能查找名称需要".你需要为节点安装类型定义吗?试试 npm i @types/node.

ERROR in src/app/p2p/p2pponent.ts(14,16): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node.

我已经安装

@types/node in app/tsconfig.app.json have add "types": [ "node" ], "typeRoots": [ "../node_modules/@types" ]

但是出现错误找不到'require'

but there is error cannot find 'require'

推荐答案

将其添加到我的 tsconfig.json 后问题仍然存在,但另外将以下行添加到 tsconfig.app.json 为我解决了它:

The problem also remained after adding it to my tsconfig.json, but additionaly adding the following line to tsconfig.app.json resolved it for me:

{ "compilerOptions": { "types": ["node"] }

所以一定要把它添加到两个文件 ./tsconfig.json 和 ./src/tsconfig.app.json 中,它应该可以工作.

So be sure to add this into both files ./tsconfig.json AND ./src/tsconfig.app.json and it should work.

更多推荐

在 angular 7 中找不到名称“要求"(打字稿 3.1.3)

本文发布于:2023-10-30 05:07:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中找   名称   angular   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!