langchain-ai / langchainjs

πŸ¦œπŸ”— Build context-aware reasoning applications πŸ¦œπŸ”—
https://js.langchain.com/docs/
MIT License
12.51k stars 2.13k forks source link

There is an issue when I install "officeparser" with the document loader pptx, terminating all my tRPC API. #3852

Closed hozaifa4you closed 5 months ago

hozaifa4you commented 9 months ago

There seems to be an issue ⚠ with loading the langchain document and the officeparser package.

Everything is running smoothly with my tRPC APIs, except for one issue I encountered while attempting to load a PowerPoint file using the langchain document loader. To fix the problem, I installed officeparser, but this caused all my tRPC APIs to stop working. Removing 'officeparser' resolved the issue and my tRPC APIs worked without any problems. However, when officeparser was installed, I received a 404 error message from tRPC.

There is an error in my terminal also

TypeError: s is not a function
at C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:13:5619
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async tE (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:13:4860)
at async tV (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:13:32468)
at async doRender (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:1294:26)
at async cacheEntry.responseCache.get.incrementalCache.incrementalCache (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:1446:28)
at async DevServer.renderToResponseWithComponentsImpl (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:1361:28)
at async DevServer.renderErrorToResponseImpl (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:1854:24)
at async DevServer.pipeImpl (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:826:25)
at async DevServer.handleCatchallRenderRequest (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\next-server.js:623:13)
at async DevServer.handleRequestImpl (C:\Users\Binary Gadget\Desktop\officeai\node_modules\next\dist\server\base-server.js:728:17)

My package.json file information:


{
"name": "officeai",
"version": "0.1.0",
"description": "This is office utils SaaS application with AI",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate"
},
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@mantine/hooks": "^7.0.1",
"@pinecone-database/pinecone": "^1.0.1",
"@prisma/client": "^5.3.1",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@sendgrid/mail": "^8.1.0",
"@tailwindcss/typography": "^0.5.10",
"@tanstack/react-query": "^4.35.3",
"@trpc/client": "^10.38.4",
"@trpc/next": "^10.38.4",
"@trpc/react-query": "^10.38.4",
"@trpc/server": "^10.38.4",
"ai": "^2.2.13",
"autoprefixer": "10.4.16",
"bcryptjs": "^2.4.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"date-fns": "^2.30.0",
"eslint-config-next": "13.5.2",
"jsonwebtoken": "^9.0.2",
"langchain": "^0.0.213",
"lodash": "^4.17.21",
"lucide-react": "^0.299.0",
"next": "^13.5.6",
"next-auth": "^4.24.5",
"openai": "^4.10.0",
"pdf-parse": "^1.1.1",
"pdfjs-dist": "^4.0.269",
"pdfreader": "^3.0.2",
"postcss": "^8.4.32",
"prisma": "^5.3.1",
"puppeteer": "^21.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.49.2",
"react-loading-skeleton": "^3.3.1",
"react-markdown": "^8.0.7",
"react-pdf": "^7.3.3",
"react-resize-detector": "^9.1.0",
"react-textarea-autosize": "^8.5.3",
"simplebar-react": "^3.2.4",
"stripe": "^13.7.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.7",
"typescript": "5.2.2",
"zod": "^3.22.4",
"zustand": "^4.4.7"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.5",
"@types/lodash": "^4.14.202",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.33.2",
"prettier": "3.1.1"
}
}


### Please give me enough information to solve the error or how to solve the error. πŸ™πŸ™πŸ™πŸ₯ΊπŸ₯Ί
dosubot[bot] commented 9 months ago

πŸ€–

Hello @hozaifa4you! πŸ‘‹

I'm Dosu, a friendly bot here to pitch in while we wait for a human maintainer. I can help troubleshoot bugs, answer your questions, and even guide you on becoming a contributor. Let's work together to resolve this issue, shall we? 😊

From the error message you provided, it seems like the issue is originating from the Next.js server. The error TypeError: s is not a function is typically thrown when a function is expected but not provided. This could be due to a variety of reasons, such as a package not being properly installed or a conflict between packages.

Given that the error occurs when you install the officeparser package, it's possible that there might be a conflict between this package and another package in your project, or that the officeparser package is not compatible with your current Node.js version.

Here are a few steps you can take to troubleshoot this issue:

  1. Check Node.js and officeparser compatibility: Ensure that your Node.js version is compatible with the officeparser package. You can check this by looking at the officeparser package documentation or its package.json file.

  2. Reinstall the officeparser package: Uninstall the officeparser package using npm uninstall officeparser, then reinstall it using npm install officeparser. This can help if the package was not properly installed the first time.

  3. Check for package conflicts: If the issue persists, try creating a new project and only install the officeparser package. If the package works in this new project, it's likely that there's a conflict with another package in your original project.

  4. Create a minimal reproducible example: If you're still experiencing the issue, try to create a minimal reproducible example. This involves creating a small project that only includes the code necessary to reproduce the issue. This can help you identify whether the issue is with the officeparser package itself, or with the way it's being used in your project.

If none of these steps resolve your issue, please provide more information about how you're using the officeparser package in your project, as well as the full error message you're seeing in your terminal. This will help me better understand the issue and provide a more accurate solution.

As for the 404 error from tRPC, it's hard to determine the cause without more information. It could be that the server route doesn't exist, or that there's an issue with the server itself. Please provide more details about how you're using tRPC in your project, and any error messages you're seeing related to tRPC.

I hope this helps! If you have any other questions, feel free to ask.

Source

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

jacoblee93 commented 9 months ago

It may be node only 😒 we will update docs accordingly

hozaifa4you commented 9 months ago

It may be node only 😒 we will update docs accordingly

But I used it only in NextJs APIs.

DeadmanAbir commented 9 months ago

Same problem with me, all my next js API routes are getting invalid after installing officeparser. Do you found any solution for this?

jacoblee93 commented 9 months ago

I don't think it's supported outside of Node envs - what if you remove export const runtime = "edge";?

dosubot[bot] commented 6 months ago

Hi, @hozaifa4you! I'm helping the langchainjs team manage their backlog and am marking this issue as stale.

It looks like you raised an issue regarding the installation of "officeparser" causing tRPC APIs to stop working, with a "TypeError: s is not a function" error message. There were responses from me providing troubleshooting steps and a suggestion to check for package conflicts, as well as a comment from @jacoblee93 indicating that "officeparser" may only be supported in Node environments. Another user, @DeadmanAbir, also reported encountering the same issue with their Next.js API routes after installing "officeparser."

Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.

Thank you for your understanding and cooperation!