问题:
\n我正在尝试构建将部署到 AWS Lambda 的 Typescript 代码。然而,在 Aws Sam 构建时,我遇到了标题中提到的错误。以下是确切的错误。
\nBuilding codeuri: D:\\AWS\\demo-app\\hello-world runtime: nodejs16.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction\nRunning NodejsNpmEsbuildBuilder:CopySource\nRunning NodejsNpmEsbuildBuilder:NpmInstall\nRunning NodejsNpmEsbuildBuilder:EsbuildBundle\n\nBuild Failed\nError: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: X [ERROR] Could not resolve "aws-sdk"\n\n app.ts:2:21:\n 2 \xe2\x94\x82 import * as AWS from 'aws-sdk';\n \xe2\x95\xb5 ~~~~~~~~~\n\n You can mark the path "aws-sdk" as external to exclude it from the bundle, which will remove this error.\n\n1 error\nchild_process.js:830\n throw err;\n ^\n\nError: Command …Run Code Online (Sandbox Code Playgroud)