在角7(打字稿3.1.3)中找不到名称’require’

前端之家收集整理的这篇文章主要介绍了在角7(打字稿3.1.3)中找不到名称’require’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的问题是为什么会出现这个错误

ERROR in src/app/p2p/p2p.component.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"
 ]

但有错误找不到’要求’

解决方法

缺少类型节点

install @ types / node:

npm install --save @types/node

要么

yarn add @types/node

编辑你的src / tsconfig.json添加

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

猜你在找的Angularjs相关文章