Closed moritzWa closed 2 months ago
Hey @moritzWa! 👋 I'm Dosu, back with some insights for you.
After reviewing the details you've provided, it's clear that the core issue stems from the epub2
library's dependency on zipfile
, which indeed has compatibility issues with Node.js versions 12 and above. This is a known issue, as you've pointed out with the reference to the node-zipfile
GitHub issue.
Given the constraints of your project, especially the need to use a Node.js version that's compatible with Prisma (which requires Node.js >= 16), downgrading Node.js isn't a viable workaround. Therefore, the most straightforward solution would be to find an alternative to the epub2
library that supports newer Node.js versions.
Here are a couple of steps you can take to move forward:
Search for Alternatives: Look for alternative libraries that can parse EPUB files and are compatible with newer Node.js versions. Libraries like epubjs
or node-epub
might offer the functionality you need without the compatibility issues. Make sure to check their documentation and GitHub issues for any known compatibility concerns.
Reach Out to LangChain Maintainers: Since epub2
is a dependency of LangChain, it would be beneficial to reach out to the LangChain maintainers. You can suggest they consider updating their dependencies to use a more modern library for EPUB parsing that supports newer Node.js versions. This would not only solve your issue but also benefit the broader LangChain user community.
Consider Contributing: If you have the capacity and interest, consider contributing to the LangChain project by suggesting or even implementing the dependency update. Open source projects greatly benefit from contributions, and this could be a great way to improve LangChain for everyone.
Temporary Workarounds: While searching for a long-term solution, you might explore temporary workarounds, such as using a microservice architecture where the EPUB parsing functionality runs in a separate service using a compatible Node.js version. This is more of a band-aid solution but might help you progress with your project in the short term.
I understand this issue is a significant roadblock for your project, and I hope these suggestions help you find a path forward. If you have any more questions or need further assistance, feel free to ask. Good luck! 🚀
My bad, the problem was that the EPubLoader
function takes only local file paths, not a URL. Might be worth clarifying this in the docs (Not sure how obvious this is for other ppl). Docs for reference:
import { EPubLoader } from "langchain/document_loaders/fs/epub";
const loader = new EPubLoader("src/document_loaders/example_data/example.epub");
const docs = await loader.load();
The problem with the server logging Module not found: Can't resolve 'zipfile' in '/Users/m/Documents/ai-quote-finder/node_modules/epub2'
remains.
So you say you can't use this in a serverless environment, like Nextjs? Usecase = someone uploads an epub on the frontend, and need to handle it with EPubLoader is not possible...
Checked other resources
Example Code
The full code of this project can be found at https://github.com/moritzWa/ai-quote-finder/
Error Message and Stack Trace (if applicable)
next build:
production error:
Description
Trying to use
EPubLoader(file.url);
throws an error.The used dependency epub2 seems to rely on zipfile which according to this ticket and my errors doesn't support node version of 12 or higher. See (node-zipfile issue).
As a workaround, I tried downgrading my Node.js version, but it's not a viable solution for my project (Prisma only supports node >= 16. I propose that the langchain library consider using a different library for parsing EPUB files, one that supports newer Node.js versions. This would make langchain more compatible with projects using newer Node.js versions.
System Info