我的问题是为什么会出现这个错误?
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?
Trynpm 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"] } }