Skip to content

YoutubeLoader throws 'module not found' error #12771

@devbydaniel

Description

@devbydaniel

System Info

Running langchain in Nextjs app

"langchain": "^0.0.175",
"next": "^13.5.2",
"react": "18.2.0",

Who can help?

@eyurtsev

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

I'm using the YoutubeLoader as described in the docs. The YoutubeLoader is part of a route handler in my NextJs application.

// in youtube service
export async function getYoutubeTranscript(youtubeUrl: string) {
  const loader = YoutubeLoader.createFromUrl(youtubeUrl, {
    language: 'en',
    addVideoInfo: true,
  })
  const docs = await loader.load()
  return docs
    .map((doc) => doc.pageContent)
    .join(' ')
    .replaceAll('\n', ' ')
}
// in route handler
const transcript = await getYoutubeTranscript(link)

When using the route, I get an error because of a missing dependency - on my machine the route still works though.
image

Manually installing canvas via npm i canvas fixes the issue, but when I deploy to vercel, the function exceeds the maximum size limit of 50 MB compressed, because the canvas package is 45 MB compressed...

Not manually installing the dependency causes the route on Vercel to always return a 405 because of the missing dependency:
image

I realize that this is not caused by the YoutubeLoader itself, but still hoping for any pointers or ideas how to fix this.

Expected behavior

YoutubeLoader works without throwing a 'module not found' error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions