欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Cannot find name ‘process‘. Do you need to install type definitions for node?

程序员文章站 2024-01-20 09:33:04
...

【问题描述】
当使用TypeScript和process时,我的规范会失败,出现如下错误消息:
Cannot find name ‘process‘. Do you need to install type definitions for node?

并且我已经在package.json文件中已经添加了@types/node类库
Cannot find name ‘process‘. Do you need to install type definitions for node?

解决办法:在tsconfig.json中配置

// tsconfig.json
{
  "compilerOptions": {
    "types": []
  }
}

改为

// tsconfig.json
{
  "compilerOptions": {
    // "types": []
  }
}

或者改为:

// tsconfig.json
{
  "compilerOptions": {
    "types": ["node"]
  }
}