Closed dantheman0207 closed 1 year ago
We're missing the exports
key, thanks for pointing it out! we'll get it fixed
Hey there! Would love to get a little bit more info on your setup for this project. Are you using js or typescript? If typescript, could you share your tsconfig
?
We used to use the exports
approach, but this doesn't work with the default moduleResolution: "node"
configuration (see https://github.com/microsoft/TypeScript/issues/50794#issue-1375081777). Instead we take an approach similar to nextjs
where we generate a bunch of top level .js
entrypoints (e.g. files like this file in the next repo)
Ideally we could continue using this approach - I have high confidence we can make it work given this is what next is doing.
You can also check out chat langchain which is an example project that imports from subpaths
Thanks! I will look at the example project more. I am not using typescript, just vanilla node. The only change I made after running node init
and autogenerating my package.json
was adding a "type": "module",
field. Here is my (lightly redacted) package.json
:
{
"name": "prototype",
"version": "1.0.0",
"description": "prototype of langchain in js",
"main": "prototype.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node prototype.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dantheman0207/XXX.git"
},
"author": "XXX",
"bugs": {
"url": "https://github.com/dantheman0207/XXX/issues"
},
"homepage": "https://github.com/dantheman0207/XXX#readme",
"dependencies": {
"langchain": "^0.0.7",
"openai": "^3.1.0",
"serpapi": "^1.1.1"
}
}
Hoping this will be solved by https://github.com/hwchase17/langchainjs/pull/54 -- I'll test with your package.json
here before we merge
EDIT: a very simple repo with your package.json
and import statement from above is working for me locally after that PR
This is live in version 0.0.8 - could you just double check if this is resolved on your end before I close?
Closing for now, can re-open if anyone is still encountering this issue
Sorry for the delay, couldn't get to this. Works for me!
Running this code:
gives me this error:
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.