[BUG] Unable to resolve path to module '@langchain/mcp-adapters'.eslintimport/no-unresolved #6

Closed
opened 2026-02-16 08:17:12 -05:00 by yindo · 9 comments
Owner

Originally created by @phpmac on GitHub (Mar 16, 2025).

Image

I have reloaded vscode,


node:internal/modules/run_main:129
    triggerUncaughtException(
    ^
Error: Cannot find package '/Users/a/Downloads/my-remix-app/node_modules/@langchain/mcp-adapters/package.json' imported from /Users/a/Downloads/my-remix-app/scripts/learn/langchainjs-mcp-adapters/client.ts
    at legacyMainResolve (node:internal/modules/esm/resolve:215:26)
    at packageResolve (node:internal/modules/esm/resolve:841:14)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at nextResolve (node:internal/modules/esm/hooks:866:28)
    at resolveBase (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:3212)
    at resolveDirectory (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:3584)
    at resolveTsPaths (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:4073)
    at async resolve (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:4441)
    at async nextResolve (node:internal/modules/esm/hooks:866:22) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v20.15.1
"@langchain/mcp-adapters": "^0.2.3",
Originally created by @phpmac on GitHub (Mar 16, 2025). <img width="1059" alt="Image" src="https://github.com/user-attachments/assets/63f6e07a-326a-43fe-b4dc-78bb7f8d7180" /> I have reloaded vscode, ``` node:internal/modules/run_main:129 triggerUncaughtException( ^ Error: Cannot find package '/Users/a/Downloads/my-remix-app/node_modules/@langchain/mcp-adapters/package.json' imported from /Users/a/Downloads/my-remix-app/scripts/learn/langchainjs-mcp-adapters/client.ts at legacyMainResolve (node:internal/modules/esm/resolve:215:26) at packageResolve (node:internal/modules/esm/resolve:841:14) at moduleResolve (node:internal/modules/esm/resolve:927:18) at defaultResolve (node:internal/modules/esm/resolve:1169:11) at nextResolve (node:internal/modules/esm/hooks:866:28) at resolveBase (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:3212) at resolveDirectory (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:3584) at resolveTsPaths (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:4073) at async resolve (file:///Users/a/.npm/_npx/fd45a72a545557e9/node_modules/tsx/dist/esm/index.mjs?1742108175144:2:4441) at async nextResolve (node:internal/modules/esm/hooks:866:22) { code: 'ERR_MODULE_NOT_FOUND' } Node.js v20.15.1 ``` "@langchain/mcp-adapters": "^0.2.3",
yindo added the bug label 2026-02-16 08:17:12 -05:00
yindo closed this issue 2026-02-16 08:17:12 -05:00
Author
Owner

@vbarda commented on GitHub (Mar 17, 2025):

Thanks for reporting -- there was a bug in the config, should be fixed in the next version. Will post here once it's released

@vbarda commented on GitHub (Mar 17, 2025): Thanks for reporting -- there was a bug in the config, should be fixed in the next version. Will post here once it's released
Author
Owner

@phpmac commented on GitHub (Mar 17, 2025):

Make langgraph great again!

@phpmac commented on GitHub (Mar 17, 2025): Make langgraph great again!
Author
Owner

@vbarda commented on GitHub (Mar 17, 2025):

Released in 0.2.4!

@vbarda commented on GitHub (Mar 17, 2025): Released in 0.2.4!
Author
Owner

@phpmac commented on GitHub (Mar 17, 2025):

Released in 0.2.4!

I have to create this new question. I have to tell you that if you use other models according to your code, an error will be prompted. I have also submitted this error in another project. Do you only test one model when testing? Or does the framework provide multiple model tests to facilitate the understanding of possible problems in different model tests?

Now you only need to use 4o-mini or other models to have this problem

@phpmac commented on GitHub (Mar 17, 2025): > Released in 0.2.4! I have to create this new question. I have to tell you that if you use other models according to your code, an error will be prompted. I have also submitted this error in another project. Do you only test one model when testing? Or does the framework provide multiple model tests to facilitate the understanding of possible problems in different model tests? *Now you only need to use 4o-mini or other models to have this problem*
Author
Owner

@phpmac commented on GitHub (Mar 17, 2025):

Released in 0.2.4!

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { ChatOpenAI } from '@langchain/openai';
import { createReactAgent } from '@langchain/langgraph/prebuilt';
import { loadMcpTools } from '@langchain/mcp-adapters';

// Initialize the ChatOpenAI model
// TODO use other model
const model = new ChatOpenAI({ modelName: 'gpt-4' });

// Create transport for stdio connection
const transport = new StdioClientTransport({
  command: 'python',
  args: ['math_server.py'],
});

// Initialize the client
const client = new Client({
  name: 'math-client',
  version: '1.0.0',
});

try {
  // Connect to the transport
  await client.connect(transport);

  // Get tools
  const tools = await loadMcpTools(client);

  // Create and run the agent
  const agent = createReactAgent({ llm: model, tools });
  const agentResponse = await agent.invoke({
    messages: [{ role: 'user', content: "what's (3 + 5) x 12?" }],
  });
  console.log(agentResponse);
} catch (e) {
  console.error(e);
} finally {
  // Clean up connection
  await client.close();
}

I mean the code here will go wrong using other models

@phpmac commented on GitHub (Mar 17, 2025): > Released in 0.2.4! ``` import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; import { ChatOpenAI } from '@langchain/openai'; import { createReactAgent } from '@langchain/langgraph/prebuilt'; import { loadMcpTools } from '@langchain/mcp-adapters'; // Initialize the ChatOpenAI model // TODO use other model const model = new ChatOpenAI({ modelName: 'gpt-4' }); // Create transport for stdio connection const transport = new StdioClientTransport({ command: 'python', args: ['math_server.py'], }); // Initialize the client const client = new Client({ name: 'math-client', version: '1.0.0', }); try { // Connect to the transport await client.connect(transport); // Get tools const tools = await loadMcpTools(client); // Create and run the agent const agent = createReactAgent({ llm: model, tools }); const agentResponse = await agent.invoke({ messages: [{ role: 'user', content: "what's (3 + 5) x 12?" }], }); console.log(agentResponse); } catch (e) { console.error(e); } finally { // Clean up connection await client.close(); } ``` I mean the code here will go wrong using other models
Author
Owner

@vbarda commented on GitHub (Mar 17, 2025):

@phpmac please open a new issue (but also it works with other models perfectly fine, including other providers - we've tested that)

@vbarda commented on GitHub (Mar 17, 2025): @phpmac please open a new issue (but also it works with other models perfectly fine, including other providers - we've tested that)
Author
Owner

@gera2ld commented on GitHub (Mar 20, 2025):

Released in 0.2.4!

And broken again in 0.3.0! 🙈

@gera2ld commented on GitHub (Mar 20, 2025): > Released in 0.2.4! And broken again in 0.3.0! 🙈
Author
Owner

@phpmac commented on GitHub (Mar 20, 2025):

Make langgraph great again!

@phpmac commented on GitHub (Mar 20, 2025): Make langgraph great again!
Author
Owner

@vbarda commented on GitHub (Mar 20, 2025):

🙈 fixed in 0.3.1 - apologies for this

@vbarda commented on GitHub (Mar 20, 2025): 🙈 fixed in 0.3.1 - apologies for this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchainjs-mcp-adapters#6