langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.23k stars 2.06k forks source link

@langchain/aws has broken dependency #6049

Open s-natsubori opened 1 month ago

s-natsubori commented 1 month ago

Checked other resources

Example Code

import { ChatBedrockConverse } from "@langchain/aws";
const model = new ChatBedrockConverse({
      model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
      region: "us-east-1",
      credentials: {
        secretAccessKey: "my-secret-key",
        accessKeyId: "my-access-key-id",
      },
    });

Error Message and Stack Trace (if applicable)

yarn install raise warning

warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-ini@3.614.0" has unmet peer dependency "@aws-sdk/client-sts@^3.614.0".
warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-web-identity@3.609.0" has unmet peer dependency "@aws-sdk/client-sts@^3.609.0".
warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-sso > @aws-sdk/token-providers@3.614.0" has unmet peer dependency "@aws-sdk/client-sso-oidc@^3.614.0".

and build dead with error


 [ERROR] No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    node_modules/@aws-sdk/token-providers/dist-es/fromSso.js:2:25:
      2 │ import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, } from "@smithy/shared-ini-file-loader";
        ╵                          ~~~~~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:3:9:
      3 │ import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";
        ╵          ~~~~~~~~~~~~~~~~~~~

(MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1649
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 2 errors:
node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:3:9: ERROR: No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"
node_modules/@aws-sdk/token-providers/dist-es/fromSso.js:2:25: ERROR: No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"
    at failureErrorWithLog ((MY_PRJ_PATH)p\node_modules\esbuild\lib\main.js:1649:15)
    at (MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1058:25
    at (MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1525:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 9,
        file: 'node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js',
        length: 19,
        line: 3,
        lineText: 'import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 25,
        file: 'node_modules/@aws-sdk/token-providers/dist-es/fromSso.js',
        length: 19,
        line: 2,
        lineText: 'import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, } from "@smithy/shared-ini-file-loader";',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"'
    }
  ],
  warnings: []
}

Description

Why @langchain/aws has unmet peer dependency? Can I solve this fix some package version???

System Info

platform :windows Node: v20.9.0 yarn: 1.22.19

"dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
}
dosubot[bot] commented 1 month ago

Hello, @s-natsubori! I'm here to help you with any questions or issues you may have. If you need assistance with bug fixes, code-related questions, or becoming a contributor, feel free to ask.

The unmet peer dependencies and build errors you're encountering with @langchain/aws are likely due to version mismatches between the @aws-sdk packages and the @smithy/shared-ini-file-loader package. To resolve these issues, you can align the versions of the @aws-sdk packages and ensure compatibility with the @smithy package.

Here are the steps to fix the package versions and resolve the unmet peer dependencies:

  1. Update @aws-sdk packages to compatible versions: Ensure that all @aws-sdk packages are using compatible versions. You can update the versions in your package.json to the latest compatible versions.

  2. Update @smithy/shared-ini-file-loader: Ensure that the @smithy/shared-ini-file-loader package is updated to a version that exports getSSOTokenFromFile.

Here is an example of how you can update your package.json:

{
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  },
  "resolutions": {
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  }
}

Additionally, ensure that all LangChain packages depend on the same instance of @langchain/core by adding appropriate fields to your project's package.json:

{
  "name": "your-project",
  "version": "0.0.0",
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "langchain": "0.0.207"
  },
  "resolutions": {
    "@langchain/core": "0.1.5"
  },
  "overrides": {
    "@langchain/core": "0.1.5"
  },
  "pnpm": {
    "overrides": {
      "@langchain/core": "0.1.5"
    }
  }
}

This should resolve the unmet peer dependencies and the build errors by ensuring that all related packages are using compatible versions. If the issue persists, you may need to check for any additional updates or compatibility issues with the specific versions of the packages you are using.

To continue talking to Dosu, mention @dosu.

s-natsubori commented 1 month ago

I try

{
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  },
  "resolutions": {
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  }
}

install warning is resolved. but still build is dead.

I did not try @langchain/core=="0.1.5" Error raise from aws-sdk, so langchain version is not problem. may be.

jacoblee93 commented 1 month ago

CC @bracesproul

bracesproul commented 1 month ago

Hey @s-natsubori I'm unable to reproduce the build error with the code sample you provided:

import { ChatBedrockConverse } from "@langchain/aws";
const model = new ChatBedrockConverse({
  model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
  region: "us-east-1",
  credentials: {
    secretAccessKey: "my-secret-key",
    accessKeyId: "my-access-key-id",
  },
});

Could you provide a public github repo which will allow be to reproduce the issue?

massi-ang commented 1 week ago

@bracesproul Hi Brace, I am facing the same issue when adding @langchain/aws to a project that uses esbuild. To reproduce you can clone and build this project: https://github.com/massi-ang/obsidian-textgenerator-plugin/tree/feat_bedrock. Note the branch in not master but feat_bedrock