迁移到无服务器 webpack 后,我的 lambda 出现大小限制错误!我已经迁移到 webpack 来解决这个问题,所以如果我仍然遇到同样的错误,那是不对的,请参阅下面的错误消息。
非常感谢!!
错误信息
发生错误:MainLambdaFunction - 资源处理程序返回消息:“解压缩大小必须小于 262144000 字节(服务:Lambda,状态代码:400,请求 ID:...,扩展请求 ID:null)”(RequestToken:... ,处理程序错误代码:无效请求)。
serverless.yml 配置
service: my-service-name
frameworkVersion: ">=1.1.0 <3.0.0"
plugins:
- serverless-webpack
custom:
webpack:
includeModules: true
packager: 'yarn'
package:
exclude:
- ./**
- "!node_modules/**"
include:
- js/**
- package.json
provider:
name: aws
runtime: nodejs12.x
stage: staging
region: eu-west-1
memorySize: 1024
timeout: 30
lambda 正在使用节点,所以我package.json
的包含在下面以供参考。
包.json 文件
"dependencies": {
"aws-sdk": "2.77.0",
"currency-formatter": "^1.2.1",
"dot": "^1.1.2",
"lodash": "4.17.4",
"moment-timezone": "0.5.33",
"pg-native": "^2.2.0",
"source-map-support": "^0.4.2",
"winston": "3.2.1",
"winston-cloudwatch": "^2.0.6"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/currency-formatter": "^1.0.1",
"@types/dot": "^1.1.2",
"@types/elasticsearch": "^5.0.19",
"@types/lodash": "4.14.71",
"@types/moment-timezone": "^0.2.34",
"@types/node": "10.17.39",
"@types/source-map-support": "^0.2.28",
"chokidar": "^2.0.3",
"chokidar-cli": "^1.2.0",
"concurrently": "^3.5.1",
"semver": "^5.3.0",
"serverless": "^1.67.3",
"serverless-webpack": "^5.6.0",
"ts-loader": "^9.2.2",
"tslint": "5.16.0",
"tslint-eslint-rules": "5.4.0",
"typescript": "^3.3.1",
"webpack": "^5.65.0",
"webpack-node-externals": "^3.0.0"
}
}