langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

Issue importing submodules using es6 module import from documentation

Open dantheman0207 opened this issue 1 year ago • 5 comments

Running this code:

import { initializeAgentExecutor } from "langchain/agents";

gives me this error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/USERXXX/Projects/langchain/prototype/javascript/node_modules/langchain/agents' imported from /Users/USERXXX/Projects/langchain/prototype/javascript/prototype.js
Did you mean to import langchain/prototype/javascript/node_modules/langchain/agents.js?

When I add the .js to the import (like this: import { initializeAgentExecutor } from "langchain/agents.js";) it works fine. This same issue occurs for all imports I've tried. It's been a while since I worked with javascript so maybe I'm missing something in the es6 module import process that's obvious but wondering if I'm doing something wrong here or whether the documentation should be updated. I assume it should work without the .js suffix.

Running node v18.13.0 on macOS Catalina 10.15.

dantheman0207 avatar Feb 18 '23 16:02 dantheman0207