typescript error - cannot find name 'process'

↘锁芯ラ 提交于 2020-06-27 07:03:20

问题


I am setting up a new project with express+ typescript and facing typescript error - cann't find name 'processs'

package.json

"dependencies": {
    "express": "^4.16.4",
    "nodemon": "^1.18.7",
    "tsc": "^1.20150623.0",
    "typescript": "^3.1.6"
  },
  "devDependencies": {
    "@types/express": "^4.16.0",
    "@types/mocha": "^5.2.5",
    "@types/node": "^10.12.10",
    "eslint": "^5.9.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-promise": "^4.0.1",
    "mocha": "^5.2.0",
    "supertest": "^3.3.0",
    "typescript-eslint-parser": "^21.0.1"
  }

I tried to follow the solution and added types tsconfig

{
    "compilerOptions": {
      "target": "es6",
      "module": "commonjs",
      "outDir": "dist",
      "sourceMap": true,
      "types": ["node"] -----
    },
    "include": [
      "src/**/*.ts"
    ],
    "exclude": [
      "node_modules"
    ]
}

But I still get the error. I have installed npm (6.4.1) and node (8.14.0) to start building up my new project. Can someone highlight what I am doing wrong?


回答1:


Your new configuration looks right. Although, you probably have to restart typescript language server if it still uses previous version of the tsconfig. In order to do this in VS Code, you do Ctrl+Shift+P and Reload Window or TypeScript: Restart TS server if available.

Also you don't need tsc package in your dependencies, because it is deprecated now, and typescript package comes with tsc executable.



来源:https://stackoverflow.com/questions/53529521/typescript-error-cannot-find-name-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!