I am in the beginning of learning the serverless framework and I am trying to setup a cicd workflow with the serverless framework pro cicd option. I am using a monorepo with two services each having a single lambda function, and am redeploying on commits to main just for experimenting. For both services however I am getting the following error.
Serverless plugin “serverless-webpack” not found. Make sure it’s installed and listed in the “plugins” section of your serverless config file. Run “serverless plugin install -n serverless-webpack” to install it.
When I simply run serverless deploy
from the command line locally the deployment succeeds.
Below are my package.json, webpack.config.js and one of the serverless.yml files. The serverless.yml’s are identical besides the path of the single function and the name.
const path = require("path");
const slsw = require("serverless-webpack");
module.exports = {
mode: "development",
externals: ["aws-sdk"],
entry: slsw.lib.entries,
devtool: slsw.lib.webpack.isLocal
? "eval-cheap-module-source-map"
: "source-map",
resolve: {
extensions: [".mjs", ".json", ".ts", ".js"],
symlinks: false,
cacheWithContext: false
},
output: {
libraryTarget: "commonjs",
path: path.join(__dirname, ".webpack")
},
target: "node",
optimization: {
nodeEnv: false
},
module: {
rules: [
{
test: /\.(tsx?)$/,
loader: "ts-loader",
exclude: [
[
path.resolve(__dirname, "node_modules"),
path.resolve(__dirname, ".serverless"),
path.resolve(__dirname, ".webpack")
]
],
options: {
transpileOnly: true,
experimentalWatchApi: true
}
}
]
}
};
{
"name": "serverless-tutorial",
"version": "1.0.0",
"description": "Learning serverless",
"scripts": {
"deploy:dev": "serverless deploy --aws-profile personal",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@tsconfig/recommended": "^1.0.1",
"@types/aws-lambda": "^8.10.77",
"@types/node": "^14.17.3",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-prettier": "^3.4.0",
"serverless": "^2.50.0",
"serverless-offline": "^6.9.0",
"serverless-webpack": "^5.4.2",
"ts-loader": "^8.3.0",
"typescript": "^4.3.5",
"webpack": "5.51.2"
}
}
org: estone
app: serverless-tutorial
service: predictions
projectDir: ../../
variablesResolutionMode: 20210326
plugins:
- serverless-webpack
- serverless-offline
package:
individually: true
custom:
deployStage: ${opt:stage, self:provider.stage}
webpack:
webpackConfig: "../../webpack.config.js"
includeModules:
packagePath: "../../package.json"
provider:
name: aws
runtime: nodejs14.x
stage: dev
apiName: ${self:app}-${self:custom.deployStage}
functions:
HelloWorld:
name: hello
handler: src/functions/hello.handler
events:
- http:
method: post
path: /predictions/hello
request:
schemas:
application/json: ${file(src/schema/hello.json)}