Elastic Beanstalk“错误TS2688:找不到“节点”的类型定义文件。”

时间:2019-05-24 11:17:25

标签: node.js amazon-web-services amazon-elastic-beanstalk

我正在尝试将应用程序部署到弹性beantalk的NodeJs平台(10.15.3),但是在构建时(Node的命令为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"
  }
}

1 个答案:

答案 0 :(得分:0)

您应将类型添加到tsconfig.json

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