Integrate tool LLM - SERPER.dev but getting error

Following the advice given on another thread that is now closed.

I have configured a lang chain tool to use SERPER but I get error.

ERROR: Cannot find module ‘langchain/tools’ [line 1]

VMError

This is apparently what happens with cloud hosted versions but I am self hosted on the latest beta version.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Robm,

The module is probably not enabled for cloud, Like the code node to access it you would likely need to set NODE_FUNCTION_ALLOW_BUILTIN or NODE_FUNCTION_ALLOW_EXTERNAL to allow the package to be used.

Thanks @Jon

I am on the self hosted latest beta version.

Would you advice apply to self hosted and how would I apply your advice? I assume somewhere in the file structure there is a file that would need editing?

Can you give me some semi laymen guidance? I have SSH access and can use nano to make file edits.

Hey @Robm,

The advice only applies to self hosted as it wouldn’t work on Cloud. The 2 options I mentioned are both environment variables so setting them would depend on how you have n8n configured but it would no different to when you set up the other n8n options.

You will need to add the name of the npm package you are trying to use then add it to the option… That being said though I just thought I would give it a go quickly and for me even after setting those options I still can’t use the serper option but we do already have a tool for SerpAPI… Is there a feature we are missing from it?

Hey @Jon thanks for the quick reply. Busy working on this right now.

SerpAPI is a lot more expensive than SERPER.dev so that is pretty much the only reason. There functionality is the same.

SERPER.dev also gives a large number of free credits which is super helpful when testing and getting set up before having to dig out the credit card.

I did find another thread where is was mention a serper.dev tool was about to be released for n8n?

I don’t think there was a plan to release a serper.dev but more of a… we could look into it. I have asked internally if anyone knows why it isn’t working as it looks like it should be good to go.

Thanks,

I am trying to edit docker-compose.yml file which is where I think I am supposed to make changes? I know you said they are not working but could you share the exact code I should add to the file. I will need to get this step done any way once this starts working.

I have n8n set up using docker using the std docker n8n installation with the recommended settings and database.

Hey @Robm,

The exact code would depend on what the package you are using would ask for. For my instance I have allowed everything for testing so I have both environment options set to *

The n8n lang chain beta package? If that is what you mean by package? (on a vertical learning curve here these past few months but still lots of gaps in my techie know how)

I have n8n set up using docker using the std docker n8n installation with the recommended settings and database.

here is my set up in the yml file. I think I have blanked out the sensitive info. I am guessing this is where I add the additional code?

environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=****
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
      - DB_SQLITE_VACUUM_ON_STARTUP=true
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=*****
      - N8N_SMTP_PORT=****
      - N8N_SMTP_USER=******
      - N8N_SMTP_PASS=******
      - N8N_SMTP_SENDER=******
      - N8N_SMTP_SSL=true

Hey @Robm,

Yeah that is it although you have some older options there that can be removed, So you could use something like the below but this will allow everything so you would need to replace the * with the name of the npm package you are using.

Please becareful with this issue as it has potential security risks if you don’t know what you are doing.

environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=****
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
      - DB_SQLITE_VACUUM_ON_STARTUP=true
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=*****
      - N8N_SMTP_PORT=****
      - N8N_SMTP_USER=******
      - N8N_SMTP_PASS=******
      - N8N_SMTP_SENDER=******
      - N8N_SMTP_SSL=true
      - NODE_FUNCTION_ALLOW_BUILTIN=*
      - NODE_FUNCTION_ALLOW_EXTERNAL=*

Once that is done you will be able to use Serper with something like…

const { Serper } = require('@n8n/n8n-nodes-langchain/node_modules/langchain/tools.cjs');
return new Serper('API_Key');

But you wouldn’t want to return serper and instead use it for whatever you are doing.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.