Problem:
Whilst developing my Code Pipeline, I am experiencing a new error I did not receive with cdk deploy --all
in the CLI. All stacks deploy successfully.
Code Build Error Message:
src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/index.ts(3,75): error TS2307: Cannot find module '@aws-sdk/client-sfn' or its corresponding type declarations.
Lambda Function Import Statements:
import { SFNClient, SendTaskSuccessCommand, SendTaskFailureCommand } from "@aws-sdk/client-sfn";
Lambda Function Package.json:
{
"name": "intomagentoqueueconsumer",
"module": "commonjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-sfn": "^3.226.0",
"axios": "^1.2.1",
"axios-retry": "^3.3.1"
}
}
Lambda Function CDK Definition:
this.intoMagentoQueueConsumer = new NodejsFunction(this, `intoMagentoQueueConsumer`, {
runtime: Runtime.NODEJS_16_X,
handler: "handler",
depsLockFilePath: join(__dirname, "../../src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/package-lock.json"),
entry: join(__dirname, "../../src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/index.ts"),
bundling: { minify: false, nodeModules: ["@aws-sdk/client-sfn", "axios", "axios-retry"], externalModules: ["aws-sdk", "crypto-js"] },
});
Porting the solution from the comments for posterity:
npm
CLI versions? AWS CodeBuild tsc error TS2307: Cannot find module.package.json
. In your pipeline ShellStep
commands, make sure you are running npm ci
for each one to install the dependencies.