Search code examples
node.jsaws-sdk

Is there any way to log the installed version of an AWS SDK client at runtime?


const { S3Client, GetBucketPolicyCommand } = require('@aws-sdk/client-s3');

I'd like to, just as a check, log the actual version of the @aws-sdk/client-s3 package at runtime. This helps us track down potential regression bugs. Reading it from package.json isn't good enough, that assumes that an install has happened between the time that json file was changed and the code was executed.

I don't see anything in the v3 docs about it.


Solution

  • It doesn't appear that the SDK objects have a version in their properties, so the only way is to read the package.json directly.

      const s3clientPackage = JSON.parse((fs.readFileSync('node_modules/@aws-sdk/client-s3/package.json')))
      console.log(`S3Client version`, s3clientPackage.version || 'none?');