Why am I Getting a Module Export Error in '@deepgram/sdk' Despite it Being Listed as Exported in the NPM Package and GitHub Repo?

This topic was automatically generated from Slack. You can find the original thread here.

:wave:Hi all, wondering if I’m doing something dumb. I’m getting a code error that “The requested module ‘@deepgram/sdk’ does not provide an export named ‘Deepgram’” based off the following import statement:
**import** { Deepgram } **from** "@deepgram/sdk";

I was wondering if there was a breaking change introduced from a new version (looks like there will be in v3, but the NPM package is still using v2), but from checking the NPM package and GitHub repo it appears the the Deepgram class is indeed exported, so I’m at a bit of a loss… Any help would be much appreciated!

Hi , you can use import * as Deepgram from "@deepgram/sdk" (1st image below). Or you can use Pipedream’s builtin Deepgram app (2nd image below)

Thanks . Unfortunately, it’s now throwing an error on this line: **const** deepgram = **new** Deepgram(**this**.deepgram.$auth.api_key) “Deepgram is not a constructor”. The source code for the npm package (attached) seems to suggest it should work fine? I feel like Pipedream is not importing the correct npm package…?

On your second suggestion, the built in Deepgram app doesn’t accomplish what I’m hoping for as I’m looking to generate a transcript based on an audio file saved in temp storage and the built in only accepts a URL as an input.

, maybe you can try this code?

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    deepgram: {
      type: "app",
      app: "deepgram",
    },
    filePath: {
      type: "string",
      label: "File Path",
      description: "Path to the audio file in tmp directory",
    },
  },
  async run({ steps, $ }) {
    const formData = new FormData();
    formData.append('file', fs.createReadStream(this.filePath));

    return await axios($, {
      method: "POST",
      url: `https://api.deepgram.com/v1/listen`,
      headers: {
        "Authorization": `Token ${this.deepgram.$auth.api_key}`,
        "Content-Type": "multipart/form-data",
      },
      data: formData,
    });
  },
});

On another note:
• I’ve added a ticket here to improve the Pipedream action: [FEATURE] Deepgram - Transcribe Audio accepts File path from tmp dir · Issue #9014 · PipedreamHQ/pipedream · GitHub
• For coding question, you can try to ask our powerful bot @U05A7KLNALC for help

Thanks, - I’ll give this a try