Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/llms' is not defined by "exports" #1431

Closed
jakewallin82 opened this issue Mar 4, 2023 · 8 comments

Comments

@jakewallin82
Copy link

I know this has to do with the ESM. I'm building a React/Typescript + Express app.

If you could please point me to a resource to figure out how to fix the issue, I would really appreciate it.

@irl-dan
Copy link

irl-dan commented Mar 4, 2023

Also running into this.

In my case:

Error: Package subpath './chains' is not defined by "exports" in /Users/.../my-project/node_modules/langchain/package.json

But indeed when I check the node_modules/langchain/package.json I can see it in there:

  "exports": {
// ...
    "./chains": {
      "types": "./chains.d.ts",
      "import": "./chains.js"
    },
// ...
}

@ImenKedir
Copy link

I am having the same issue.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './llms' is not defined by "exports" in /Users/.../project/node_modules/langchain/package.json

@jcoc611
Copy link

jcoc611 commented Mar 5, 2023

Running into this as well. Seems that the problem is that package.json is missing CommonJS "require": "foo.js" under the exports subpaths, so it isn't possible to import them from CommonJS?

@Rolilink
Copy link

Rolilink commented Mar 5, 2023

Having the same issue, I am using nx and typescript in my project:

tsconfig:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "module": "commonjs",
    "types": ["node"]
  },
  "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
  "include": ["src/**/*.ts"]
}

Webpack config:

{
  context: '/Users/rolilink/Dev/Hirai/apps/hirai-graph-server',
  target: 'node',
  node: false,
  mode: 'development',
  devtool: 'source-map',
  entry: {
    main: [ '/Users/rolilink/Dev/Hirai/apps/hirai-graph-server/src/main.ts' ]
  },
  output: {
    libraryTarget: 'commonjs',
    path: '/Users/rolilink/Dev/Hirai/dist/apps/hirai-graph-server',
    filename: '[name].js',
    chunkFilename: '[name].js',
    hashFunction: 'xxhash64',
    pathinfo: false,
    scriptType: 'module'
  },
  watch: true,
  watchOptions: { poll: undefined },
  profile: false,
  resolve: {
    extensions: [ '.ts', '.tsx', '.mjs', '.js', '.jsx' ],
    alias: {},
    plugins: [ [TsconfigPathsPlugin] ],
    mainFields: [ 'main', 'module' ]
  },
  externals: [ [Function (anonymous)] ],
  optimization: {
    sideEffects: true,
    minimize: false,
    minimizer: [ [TerserPlugin] ],
    runtimeChunk: false,
    concatenateModules: true
  },
  performance: { hints: false },
  experiments: { cacheUnaffected: true },
  ignoreWarnings: [ [Function (anonymous)] ],
  module: {
    unsafeCache: true,
    rules: [ [Object], [Object], [Object], [Object] ]
  },
  plugins: [
    ForkTsCheckerWebpackPlugin { options: [Object] },
    CopyPlugin { patterns: [Array], options: {} }
  ],
  stats: {
    hash: true,
    timings: false,
    cached: false,
    cachedAssets: false,
    modules: false,
    warnings: true,
    errors: true,
    colors: true,
    chunks: true,
    assets: false,
    chunkOrigins: false,
    chunkModules: false,
    children: false,
    reasons: false,
    version: false,
    errorDetails: false,
    moduleTrace: false,
    usedExports: false
  }
}

@irl-dan
Copy link

irl-dan commented Mar 6, 2023

I'm realizing this is the wrong repository for this issue. Linking to the correct issue here:

langchain-ai/langchainjs#185

@dosubot
Copy link

dosubot bot commented Sep 21, 2023

Hi, @jakewallin82! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you encountered an error related to ESM (ECMAScript Modules) in a React/Typescript + Express app. You were seeking guidance or resources to resolve the issue. Other users have also reported encountering the same error and have provided additional information and suggestions. One user suggested that the problem may be due to missing CommonJS require statements in the package.json file. Another user shared their project's tsconfig and Webpack configuration.

However, it seems that the issue is still unresolved. Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding, and we look forward to hearing from you soon!

Best regards,
Dosu

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 21, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 28, 2023
@OmarKhattab
Copy link

Hi, @jakewallin82! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you encountered an error related to ESM (ECMAScript Modules) in a React/Typescript + Express app. You were seeking guidance or resources to resolve the issue. Other users have also reported encountering the same error and have provided additional information and suggestions. One user suggested that the problem may be due to missing CommonJS require statements in the package.json file. Another user shared their project's tsconfig and Webpack configuration.

However, it seems that the issue is still unresolved. Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding, and we look forward to hearing from you soon!

Best regards, Dosu

This is still an issue

@a-box31
Copy link

a-box31 commented Sep 16, 2024

check the directory of the langchain model in here at langchain.js. Usually the extension is from the community section of their API.

so npm install @lanchain/community

then in the import, using es6 modules in the package.json, run the following

import { YOUR_FUNCTION } from @langchain/community/llms/{YOUR_MODEL}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants