打字稿错误

编程入门 行业动态 更新时间:2024-10-03 19:12:38

打字稿<a href=https://www.elefans.com/category/jswz/34/1771449.html style=错误"/>

打字稿错误

我正在使用 express+ typescript 设置一个新项目并面临 typescript 错误 - 找不到名称“进程”

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"
  }

我试着按照 solution 并添加类型 ts配置

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

但我仍然得到错误。我已经安装了 npm (6.4.1) 和 node (8.14.0) 来开始构建我的新项目。有人可以强调我做错了什么吗?

回答如下:

你的新配置看起来不错。虽然,如果它仍然使用以前版本的 tsconfig,您可能必须重新启动 typescript 语言服务器。为了在 VS Code 中执行此操作,您可以执行

Ctrl+Shift+P
Reload Window
TypeScript: Restart TS server
(如果可用)。

此外,您的依赖项中不需要

tsc
包,因为它现在已被弃用,并且
typescript
包附带
tsc
可执行文件。

更多推荐

打字稿错误

本文发布于:2024-05-31 05:22:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!