We're experiencing the following error while trying to deploy in AWS Pipeline:
The container image is aws/codebuild/standard:7.0.
The previous install commands before attempting to deploy:
- n install 22
- node --version
- npm install -g serverless@3.38.0
- npm install --save-dev serverless-prune-plugin
- npm install -g lodash
Then we try to deploy:
- serverless plugin install -n serverless-apigateway-service-proxy
- serverless deploy --verbose --stage $STAGE --region us-east-1
But we get the following error:
✔ Plugin "serverless-apigateway-service-proxy" installed (2s)
[Container] 2025/05/23 01:21:54.707107 Running command serverless deploy --verbose --stage $STAGE --region us-east-1
Environment: linux, node 22.16.0, framework 3.38.0, plugin 7.2.3, SDK 4.5.1
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Error: Cannot find module 'lodash'
Require stack:
- /codebuild/output/src1487062427/src/node_modules/serverless-apigateway-service-proxy/lib/apiGateway/validate.js
- /codebuild/output/src1487062427/src/node_modules/serverless-apigateway-service-proxy/lib/index.js
- /usr/local/lib/node_modules/serverless/lib/utils/require-with-import-fallback.js
- /usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js
- /usr/local/lib/node_modules/serverless/lib/serverless.js
- /usr/local/lib/node_modules/serverless/scripts/serverless.js
- /usr/local/lib/node_modules/serverless/bin/serverless.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1487:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/codebuild/output/src1487062427/src/node_modules/serverless-apigateway-service-proxy/lib/apiGateway/validate.js:3:11)
at Module._compile (node:internal/modules/cjs/loader:1730:14)
at Object..js (node:internal/modules/cjs/loader:1895:10)
at Module.load (node:internal/modules/cjs/loader:1465:32)
at Function._load (node:internal/modules/cjs/loader:1282:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1487:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/codebuild/output/src1487062427/src/node_modules/serverless-apigateway-service-proxy/lib/index.js:5:18)
at Module._compile (node:internal/modules/cjs/loader:1730:14)
at Object..js (node:internal/modules/cjs/loader:1895:10)
at Module.load (node:internal/modules/cjs/loader:1465:32)
at Function._load (node:internal/modules/cjs/loader:1282:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1487:12)
at require (node:internal/modules/helpers:135:16)
at module.exports (/usr/local/lib/node_modules/serverless/lib/utils/require-with-import-fallback.js:5:12)
at PluginManager.requireServicePlugin (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:171:14)
at PluginManager.resolveServicePlugins (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:198:29)
at PluginManager.loadAllPlugins (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:136:47)
at Serverless.init (/usr/local/lib/node_modules/serverless/lib/serverless.js:146:30)
at async /usr/local/lib/node_modules/serverless/scripts/serverless.js:601:7
[Container] 2025/05/23 01:21:56.298091 Command did not exit successfully serverless deploy --verbose --stage $STAGE --region us-east-1 exit status 1
[Container] 2025/05/23 01:21:56.303194 Phase complete: BUILD State: FAILED
[Container] 2025/05/23 01:21:56.303214 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: serverless deploy --verbose --stage $STAGE --region us-east-1. Reason: exit status 1
[Container] 2025/05/23 01:21:56.341486 Entering phase POST_BUILD
Please note we were using image 5.0 and node 18 but the error was the same. I thought it was the image version or the node version so I bumped it but I still see the error.
We have other projects with t he same version of serverless framework but that DO NOT use the serverless-apigateway-service-proxy plugin and these DO NOT fail. This is why I'm posting this issue here rather than in the serverless repo.
Also, about a month ago we deployed this same pipeline without changes in versions just fine. But recently, it started to fail.
We're experiencing the following error while trying to deploy in AWS Pipeline:
The container image is
aws/codebuild/standard:7.0.The previous install commands before attempting to deploy:
Then we try to deploy:
But we get the following error:
Please note we were using image 5.0 and node 18 but the error was the same. I thought it was the image version or the node version so I bumped it but I still see the error.
We have other projects with t he same version of serverless framework but that DO NOT use the
serverless-apigateway-service-proxyplugin and these DO NOT fail. This is why I'm posting this issue here rather than in the serverless repo.Also, about a month ago we deployed this same pipeline without changes in versions just fine. But recently, it started to fail.