Langchain n8n example: Package path './dist/tools' is not exported null

Hi everybody, I’m trying to check one example about langchain, but I have a problem when I run the free example:

I update Custom - LLM Chain Node: const { PromptTemplate } = require(‘langchain/prompts’); to const { PromptTemplate } = require(‘@langchain/core/prompts’);

And

I update Custom - Wikipedia: const { WikipediaQueryRun } = require(‘langchain/tools’); to const { WikipediaQueryRun } = require(‘@langchain/community/dist/tools’);

But in this last code, there is a error:

Error in sub-node ‘Custom - Wikipedia’

Package path ‘./dist/tools’ is not exported null Open node

Error details

Other info

Item Index

0

Node type

@n8n/n8n-nodes-langchain.code

Node version

1 (Latest)

n8n version

1.60.1 (Self Hosted)

Time

30/9/2024, 8:51:33 p. m.

Stack trace

NodeOperationError: Error in sub-node Custom - Wikipedia at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/NodeExecuteFunctions.ts:2897:11 at async Promise.all (index 0) at Object.getInputConnectionData (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/NodeExecuteFunctions.ts:2906:16) at Object.getInputConnectionData (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/NodeExecuteFunctions.ts:3684:12) at getConnectedTools (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/utils/helpers.ts:183:5) at Object.conversationalAgentExecute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/nodes/agents/Agent/agents/ConversationalAgent/execute.ts:33:16) at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/nodes/agents/Agent/Agent.node.ts:392:11) at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1382:8) at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1080:27 at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1800:11

Agent1

Test step

Parameters

Settings


Docs

Tip: Get a feel for agents with our quick tutorial or see an example of how this node works

Agent

Text

Fixed

Expression

{{ $json.input }}

What year was Einstein born?

Options

No properties

Chat Model *

Memory

Tool

Output Parser

I wish this node would…

Waiting for you to submit the chat

Information on your n8n setup

  • n8n version: 1.60.1
  • Running n8n via (Docker, desktop app):
  • Operating system: windows

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:
1 Like

The location you’re trying to import the tool from is incorrect. Try the following instead.

const { WikipediaQueryRun } = require( '@langchain/community/tools/wikipedia_query_run');
return new WikipediaQueryRun();

You can check out what else is available by ssh’ing into the docker container and running the following command.

ls -la /usr/local/lib/node_modules/n8n/node_modules/@langchain/community/tools/
1 Like

Thank you so much Jim, it worked perfect.

I used this code and found this, but It doesn’t work:

ls -l /usr/local/lib/node_modules/n8n/node_modules/@langchain/community/dist/tools

total 456
-rw-r–r-- 1 root root 2751 Oct 1 01:29 aiplugin.cjs
-rw-r–r-- 1 root root 1171 Oct 1 01:30 aiplugin.d.ts
,…
-rw-r–r-- 1 root root 2225 Oct 1 01:30 tavily_search.d.ts
-rw-r–r-- 1 root root 4048 Oct 1 01:30 tavily_search.js
-rw-r–r-- 1 root root 6093 Oct 1 01:29 wikipedia_query_run.cjs
-rw-r–r-- 1 root root 3089 Oct 1 01:30 wikipedia_query_run.d.ts
-rw-r–r-- 1 root root 5928 Oct 1 01:30 wikipedia_query_run.js
-rw-r–r-- 1 root root 1508 Oct 1 01:29 wolframalpha.cjs
-rw-r–r-- 1 root root 492 Oct 1 01:30 wolframalpha.d.ts
-rw-r–r-- 1 root root 1346 Oct 1 01:30 wolframalpha.js

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