I have an AWS lambda function triggered by an SNS queue, which is supposed to extract some data from the message it receives, format it, then send it to a different SNS queue. Everything was working well until I tried sending to the second queue. In order to do so, I installed @aws-sdk/client-sns, and attempted to send a simple message. When I run the code, it's throwing the following error related to not being able to find TypeScript definitions:
ā in ./node_modules/@aws-sdk/client-sns/dist-es/index.js 1:0-22
Module not found: Error: Can't resolve './SNS' in '/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es'
resolve './SNS' in '/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es'
using description file: /Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/package.json (relative path: ./dist-es)
using description file: /Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/package.json (relative path: ./dist-es/SNS)
no extension
/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es/SNS doesn't exist
.ts
/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es/SNS.ts doesn't exist
tsx
/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es/SNStsx doesn't exist
as directory
/Users/userName/development/aws-sdk-error/node_modules/@aws-sdk/client-sns/dist-es/SNS doesn't exist
This is the simplified version of the file throwing the error:
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
export const showError = async () => {
const client = new SNSClient( { region: 'us-west-1' } );
const params = {
Message: 'some text',
TopicArn: 'arn:aws:sns:us-east-1:111111111111:someOtherTopic'
};
try {
await client.send( new PublishCommand( params ));
} catch ( error ) {
}
};
I've been searching for hours and haven't been able to pinpoint the issue, although I've tried changing values in my tsconfig.json file and have tried multiple versions of Node (14.x, 16.x, 18.x), but would like to use 16.15.0. Any help figuring this out would be greatly appreciated.
I've created a sample repo on Github showing the error in action: https://github.com/autoboxer/aws-sdk-error