错误"/>
打字稿错误
我正在使用 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
可执行文件。
更多推荐
打字稿错误
发布评论