[英]AWS CDK Code Pipeline Development - Typescript Error TS2307
Problem:问题:
Whilst developing my Code Pipeline, I am experiencing a new error I did not receive with cdk deploy --all
in the CLI.在开发我的代码管道时,我遇到了一个新错误,我没有在 CLI 中使用cdk deploy --all
收到这个错误。 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: Lambda Function 进口报表:
import { SFNClient, SendTaskSuccessCommand, SendTaskFailureCommand } from "@aws-sdk/client-sfn";
Lambda Function Package.json: 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: Lambda Function CDK定义:
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?您是否有不匹配npm
CLI 版本? AWS CodeBuild tsc error TS2307: Cannot find module . AWS CodeBuild tsc 错误 TS2307:找不到模块。package.json
.我了解您的项目有多个package.json
。 In your pipeline ShellStep
commands, make sure you are running npm ci
for each one to install the dependencies.在您的管道ShellStep
命令中,确保为每个命令运行npm ci
以安装依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.