#Issue Deploying to Vercel using LangChain JS & NEXT JS 14

42 messages · Page 1 of 1 (latest)

stiff wharf
#

Hello, i encountered this error while trying to deploy a test to vercel...

next build
▲ Next.js 14.0.2
Creating an optimized production build ...
Failed to compile.
./node_modules/langchain/dist/chains/question_answering/refine_prompts.js + 4 modules
Cannot get final name for export 'PromptTemplate' of ./node_modules/langchain/dist/prompts/index.js

Build failed because of webpack errors
Error: Command "npm run build" exited with 1

locally works perfect thinkies

sterile parrotBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

frigid birchBOT
# stiff wharf Hello, i encountered this error while trying to deploy a test to vercel... next...
Please add more information to your question

Your question currently does not have sufficient information for people to be able to help. Please add more information to help us help you, for example: relevant code snippets, a reproduction repository, and/or more detailed error messages. See more info on how to ask a good question in https://discord.com/channels/752553802359505017/1138338531983491154 and #welcome message

amber sleet
#

Did you find a fix?

stiff wharf
# amber sleet Did you find a fix?

not yet, i only found people who said something about maybe being related to TS types error... but nothing really with evidence of the error

amber sleet
#

Meh i cant make it work and am stuck

native palm
#

When you say it works locally does it also build locally ?

#

Try going to to your next.config and adding this

#
 module.exports =  {
    ...otherstuff
    future : {
    webpack5: true,
}  
},
amber sleet
#

still the same issue here

native palm
#

Ok so when I looked online I saw this issue

https://github.com/langchain-ai/langchainjs/issues/2335

They've suggested to add the following :


module.exports = {
  swcMinify: false,
  webpack5: {
    module: {
      rules: [
        {
          test: /node_modules\/langchain/,
          resolve: {
            fullySpecified: false,
          },
        },
      ],
    },
  },
};```
GitHub

When building a project in Next.js version 13.4, getting this error: Cannot get final name for export 'PromptTemplate' of ./node_modules/langchain/dist/prompts/index.js It's breaking th...

native palm
#

Apparently this issue steps from the minification process..

Another suggestion was to remove the following

    serverActions: true,

However, this may have some implications if you're currently using serverActions of course

amber sleet
#

Im using Server Actions

native palm
#

In that case try that first suggestion but it seems to be a common issue with nextJS 14 and server actions now that I am reading into it which is a shame because apparently with this release its meant to be stable hopefully they come up with a fix for it soon.

amber sleet
#

Because im basically stuck now haha

#

Cannot just remove Langchain from my project

native palm
#

Yeah its a huge blocker and tbh frustrating that this is even an issue as its been around since next 13 apparently in the experimental version

#

But surely there has to be a work around I am looking through the forums now to learn more about it.. And to confirm it builds locally? when you run the build command

amber sleet
#

npm run dev is fine but npm run build gives this error

amber sleet
#

So annoying

stiff wharf
#

haven't found a fix for this, been trying a lot of suggestions but nothing yet

stiff wharf
#

@amber sleet are you using the VERCEL AI SDK?

amber sleet
#

No

#

Just Langchain

#

Its annoying

#

And because op Server Actions

stiff wharf
#

I FOUND A SOLUTION @amber sleet

#

just import the PropmtTemplate anywhere and make sure you call it

amber sleet
#

Haha omggg

#

Really

#

I’ll try in a bit!

amber sleet
#

Works!

#

hahah nice one pfff

stiff wharf