node.js - Elastic Beanstalk “错误 TS2688:找不到‘节点’的类型定义文件。”
问题描述
我正在尝试将应用程序部署到弹性 beantalk 的 NodeJs 平台(10.15.3),但随着它的构建(节点命令是npm start --production
),我在日志中看到以下错误:
npm run build
app@1.0.0 build /var/app/current
tsc -p .
error TS2688: Cannot find type definition file for 'node'.
我的 package.json 如下(它包括 @type/node:10.14):
{
"name": "app",
"version": "1.0.0",
"private": true,
"main": "dist/app.js",
"scripts": {
"build": "tsc -p .",
"prestart": "npm run build",
"watch": "tsc -w -p .",
"start": "node .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@types/morgan": "^1.7.35",
"@types/node": "^10.14",
"aws-sdk": "^2.411.0",
...
},
"devDependencies": {
"@types/express": "^4.16.1"
}
}
解决方案
您应该将类型添加到您的tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist-api",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"types": ["node"]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
推荐阅读
- html - Srcset 似乎找不到正确的图像
- rust - 使用参考枢轴循环时出现可变借用问题
- rust - 如何使用潮汐和glommio将错误传播回调用者?
- python - 使用方法链接分配给 Pandas 数据框
- azure-active-directory - 在 Azure AD 应用程序对象上设置 AppId uri 时获取“HostNameNotOnVerifiedDomain”
- javascript - 如何使用javascript在href中获取标签值
- python - Python3 Pandas 键错误:0
- spss - 比较或组合列中的值
- r - 在字符之间添加逗号
- javascript - 如何使用条件语句更新 eventlistner 内的变量号