打字稿,“进程”不存在

Sep*_*eed 3 node.js

我安装了npm i @types/node,但进程仍然没有注册为现有的。我还需要做什么才能获得节点的类型定义?

Sep*_*eed 6

您不仅必须安装节点的类型(即npm i @types/node),还必须在 tsconfig.json 中的“types”下列出“node”

// example tsconfig.json
{
  "compilerOptions": {
    "module": "CommonJS",
    "target": "ES2018",
    "baseUrl": ".",
    "importHelpers": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "types": ["node"]
  }
}
Run Code Online (Sandbox Code Playgroud)