langchain-ai / langchainjs

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

Unable to do local build of langchainjs project with dev container #5952

Closed deefactorial closed 5 days ago

deefactorial commented 6 days ago

Checked other resources

Example Code

yarn install

Error Message and Stack Trace (if applicable)

node ➜ /workspaces/langchainjs (main) $ yarn install ➤ YN0000: ┌ Project validation ➤ YN0057: │ core_docs: Resolutions field will be ignored ➤ YN0000: └ Completed ➤ YN0000: ┌ Resolution step ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide @algolia/client-search (pbc410), requested by @algolia/autocomplete-shared ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide algoliasearch (p8ad5b), requested by @algolia/autocomplete-shared ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide search-insights (pfdb70), requested by @algolia/autocomplete-plugin-algolia-insights ➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide @algolia/client-search (pdf3b9), requested by @algolia/autocomplete-shared ➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide algoliasearch (p0f6bb), requested by @algolia/autocomplete-shared ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.583.0 doesn't provide @aws-sdk/client-sts (p51977), requested by @aws-sdk/credential-provider-web-identity ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.583.0 doesn't provide @aws-sdk/client-sts (p07936), requested by @aws-sdk/credential-provider-ini ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.592.0 doesn't provide @aws-sdk/client-sts (p42e5a), requested by @aws-sdk/credential-provider-web-identity ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.592.0 doesn't provide @aws-sdk/client-sts (p82305), requested by @aws-sdk/credential-provider-ini ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.600.0 doesn't provide @aws-sdk/client-sts (pfbe48), requested by @aws-sdk/credential-provider-web-identity ➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.600.0 doesn't provide @aws-sdk/client-sts (p1279e), requested by @aws-sdk/credential-provider-ini ➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.583.0 doesn't provide @aws-sdk/client-sso-oidc (p34559), requested by @aws-sdk/token-providers ➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.592.0 doesn't provide @aws-sdk/client-sso-oidc (pb5495), requested by @aws-sdk/token-providers ➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.598.0 doesn't provide @aws-sdk/client-sso-oidc (p3b6af), requested by @aws-sdk/token-providers ➤ YN0002: │ @docsearch/react@npm:3.5.2 [2501b] doesn't provide @algolia/client-search (pfbb58), requested by @algolia/autocomplete-preset-algolia ➤ YN0002: │ @langchain/community@workspace:libs/langchain-community doesn't provide @babel/runtime (p19e9d), requested by typesense ➤ YN0060: │ @langchain/community@workspace:libs/langchain-community provides @langchain/core (pe2241) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0060: │ @langchain/community@workspace:libs/langchain-community provides langchain (p2dd11) with version 0.2.3, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0002: │ @langchain/community@workspace:libs/langchain-community [0319f] doesn't provide @babel/runtime (p9268d), requested by typesense ➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides @langchain/core (p9797d) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides langchain (p1721c) with version 0.2.3, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides mongodb (pe3514) with version 5.2.0, which doesn't satisfy what typeorm requests ➤ YN0002: │ @langchain/google-common@npm:0.0.18 doesn't provide zod (p73392), requested by zod-to-json-schema ➤ YN0060: │ @langchain/standard-tests@workspace:libs/langchain-standard-tests provides zod (p117e8) with version 3.22.4, which doesn't satisfy what zod-to-json-schema requests ➤ YN0002: │ core_docs@workspace:docs/core_docs doesn't provide @babel/core (p52994), requested by @babel/eslint-parser ➤ YN0002: │ core_docs@workspace:docs/core_docs doesn't provide typescript (p16606), requested by typedoc ➤ YN0002: │ crlf-normalize@npm:1.0.18 doesn't provide ts-toolbelt (pd32c8), requested by ts-type ➤ YN0002: │ examples@workspace:examples doesn't provide @babel/runtime (pd2afb), requested by typesense ➤ YN0060: │ examples@workspace:examples provides @langchain/core (pc67be) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0002: │ examples@workspace:examples doesn't provide @tensorflow/tfjs-core (pe7130), requested by @tensorflow/tfjs-backend-cpu ➤ YN0060: │ examples@workspace:examples provides @typescript-eslint/eslint-plugin (pd11cb) with version 5.54.1, which doesn't satisfy what eslint-plugin-unused-imports requests ➤ YN0060: │ examples@workspace:examples provides langchain (pf2ed0) with version 0.2.8, which doesn't satisfy what @getzep/zep-cloud requests ➤ YN0060: │ examples@workspace:examples provides mongodb (p2c5ac) with version 6.3.0, which doesn't satisfy what typeorm requests ➤ YN0060: │ langchain@workspace:langchain [e0604] provides mongodb (pa6132) with version 5.2.0, which doesn't satisfy what typeorm requests ➤ YN0060: │ langchain@workspace:langchain [fadf1] provides mongodb (p882b8) with version 5.2.0, which doesn't satisfy what typeorm requests ➤ YN0002: │ weaviate-ts-client@npm:1.4.0 doesn't provide graphql (p06027), requested by graphql-request ➤ YN0002: │ weaviate-ts-client@npm:2.0.0 doesn't provide graphql (p6c7c6), requested by graphql-request ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements for details, where is the six-letter p-prefixed code ➤ YN0000: └ Completed in 0s 425ms ➤ YN0000: ┌ Fetch step ➤ YN0013: │ @types/crypto-js@npm:4.2.2 can't be found in the cache and will be fetched from the remote registry ➤ YN0013: │ @types/d3-dsv@npm:2.0.3 can't be found in the cache and will be fetched from the remote registry ➤ YN0013: │ @types/decamelize@npm:1.2.0 can't be found in the cache and will be fetched from the remote registry ➤ YN0013: │ @types/dns-packet@npm:5.6.5 can't be found in the cache and will be fetched from the remote registry ➤ YN0013: │ @types/dompurify@npm:3.0.5 can't be found in the cache and will be fetched from the remote registry ➤ YN0000: ⠋ ============================---------------------------------------------------- Killed

Description

node ➜ /workspaces/langchainjs (main) $ yarn install
➤ YN0000: ┌ Project validation
➤ YN0057: │ core_docs: Resolutions field will be ignored
➤ YN0000: └ Completed
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide @algolia/client-search (pbc410), requested by @algolia/autocomplete-shared
➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide algoliasearch (p8ad5b), requested by @algolia/autocomplete-shared
➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide search-insights (pfdb70), requested by @algolia/autocomplete-plugin-algolia-insights
➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide @algolia/client-search (pdf3b9), requested by @algolia/autocomplete-shared
➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide algoliasearch (p0f6bb), requested by @algolia/autocomplete-shared
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.583.0 doesn't provide @aws-sdk/client-sts (p51977), requested by @aws-sdk/credential-provider-web-identity
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.583.0 doesn't provide @aws-sdk/client-sts (p07936), requested by @aws-sdk/credential-provider-ini
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.592.0 doesn't provide @aws-sdk/client-sts (p42e5a), requested by @aws-sdk/credential-provider-web-identity
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.592.0 doesn't provide @aws-sdk/client-sts (p82305), requested by @aws-sdk/credential-provider-ini
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.600.0 doesn't provide @aws-sdk/client-sts (pfbe48), requested by @aws-sdk/credential-provider-web-identity
➤ YN0002: │ @aws-sdk/credential-provider-node@npm:3.600.0 doesn't provide @aws-sdk/client-sts (p1279e), requested by @aws-sdk/credential-provider-ini
➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.583.0 doesn't provide @aws-sdk/client-sso-oidc (p34559), requested by @aws-sdk/token-providers
➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.592.0 doesn't provide @aws-sdk/client-sso-oidc (pb5495), requested by @aws-sdk/token-providers
➤ YN0002: │ @aws-sdk/credential-provider-sso@npm:3.598.0 doesn't provide @aws-sdk/client-sso-oidc (p3b6af), requested by @aws-sdk/token-providers
➤ YN0002: │ @docsearch/react@npm:3.5.2 [2501b] doesn't provide @algolia/client-search (pfbb58), requested by @algolia/autocomplete-preset-algolia
➤ YN0002: │ @langchain/community@workspace:libs/langchain-community doesn't provide @babel/runtime (p19e9d), requested by typesense
➤ YN0060: │ @langchain/community@workspace:libs/langchain-community provides @langchain/core (pe2241) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0060: │ @langchain/community@workspace:libs/langchain-community provides langchain (p2dd11) with version 0.2.3, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0002: │ @langchain/community@workspace:libs/langchain-community [0319f] doesn't provide @babel/runtime (p9268d), requested by typesense
➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides @langchain/core (p9797d) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides langchain (p1721c) with version 0.2.3, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0060: │ @langchain/community@workspace:libs/langchain-community [0319f] provides mongodb (pe3514) with version 5.2.0, which doesn't satisfy what typeorm requests
➤ YN0002: │ @langchain/google-common@npm:0.0.18 doesn't provide zod (p73392), requested by zod-to-json-schema
➤ YN0060: │ @langchain/standard-tests@workspace:libs/langchain-standard-tests provides zod (p117e8) with version 3.22.4, which doesn't satisfy what zod-to-json-schema requests
➤ YN0002: │ core_docs@workspace:docs/core_docs doesn't provide @babel/core (p52994), requested by @babel/eslint-parser
➤ YN0002: │ core_docs@workspace:docs/core_docs doesn't provide typescript (p16606), requested by typedoc
➤ YN0002: │ crlf-normalize@npm:1.0.18 doesn't provide ts-toolbelt (pd32c8), requested by ts-type
➤ YN0002: │ examples@workspace:examples doesn't provide @babel/runtime (pd2afb), requested by typesense
➤ YN0060: │ examples@workspace:examples provides @langchain/core (pc67be) with version 0.2.11, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0002: │ examples@workspace:examples doesn't provide @tensorflow/tfjs-core (pe7130), requested by @tensorflow/tfjs-backend-cpu
➤ YN0060: │ examples@workspace:examples provides @typescript-eslint/eslint-plugin (pd11cb) with version 5.54.1, which doesn't satisfy what eslint-plugin-unused-imports requests
➤ YN0060: │ examples@workspace:examples provides langchain (pf2ed0) with version 0.2.8, which doesn't satisfy what @getzep/zep-cloud requests
➤ YN0060: │ examples@workspace:examples provides mongodb (p2c5ac) with version 6.3.0, which doesn't satisfy what typeorm requests
➤ YN0060: │ langchain@workspace:langchain [e0604] provides mongodb (pa6132) with version 5.2.0, which doesn't satisfy what typeorm requests
➤ YN0060: │ langchain@workspace:langchain [fadf1] provides mongodb (p882b8) with version 5.2.0, which doesn't satisfy what typeorm requests
➤ YN0002: │ weaviate-ts-client@npm:1.4.0 doesn't provide graphql (p06027), requested by graphql-request
➤ YN0002: │ weaviate-ts-client@npm:2.0.0 doesn't provide graphql (p6c7c6), requested by graphql-request
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 425ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ @types/crypto-js@npm:4.2.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @types/d3-dsv@npm:2.0.3 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @types/decamelize@npm:1.2.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @types/dns-packet@npm:5.6.5 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @types/dompurify@npm:3.0.5 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: ⠋ ============================----------------------------------------------------
Killed
node ➜ /workspaces/langchainjs (main) $ yarn build
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)

$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...

System Info

node ➜ /workspaces/langchainjs (main) $ yarn info langchain
Usage Error: No package matched your request

$ yarn info [-A,--all] [-R,--recursive] [-X,--extra #0] [--cache] [--dependents] [--manifest] [--name-only] [--virtuals] [--json] ...

Platform: mac node -v: v20.2.0 yarn --version: 3.4.1

dosubot[bot] commented 6 days ago

To resolve the issues with yarn install and yarn build in the LangChain.js project when using a dev container, follow these steps:

  1. Ensure Node.js Version: Make sure the Node.js version in the dev container is >=18.

  2. Use Correct Yarn Version: Use Yarn version 3.4.1.

  3. Install Dependencies: Run yarn install to install all dependencies. Ensure the dev container has internet access and the necessary permissions to install packages.

  4. Build Command: Use the build script defined in the package.json:

    yarn build

Here is a sample Dockerfile for setting up the dev container:

FROM node:18

# Set working directory
WORKDIR /usr/src/app

# Copy package.json and yarn.lock
COPY package.json yarn.lock ./

# Install Yarn 3.4.1
RUN npm install -g yarn@3.4.1

# Install dependencies
RUN yarn install

# Copy the rest of the application code
COPY . .

# Build the project
RUN yarn build

# Expose the port the app runs on
EXPOSE 3000

# Command to run the app
CMD ["yarn", "start"]

Ensure that the Dockerfile is placed in the root of your project directory and build the Docker image using:

docker build -t langchainjs-dev .

Then run the container:

docker run -it -p 3000:3000 langchainjs-dev

Additionally, the package.json file in the LangChain.js project includes several build-related scripts that might be useful:

For more detailed instructions on contributing to the LangChain.js project, including setting up a development container, you can refer to the Contribute Code section in the documentation [1][2][3].

To continue talking to Dosu, mention @dosu.

deefactorial commented 6 days ago

I've tried the node 18 dev container and it didn't change the output. I also tried updating the yarn version to the latest with sudo corepack enable && corepack prepare yarn@stable --activate && yarn set version latest && yarn install but still did not help. I tried pnpm install and npm install but that did not help either.

lamoglia commented 5 days ago

Hi @deefactorial , I managed to simulate the problem here and got the same results. I believe that this is happening because the requirements for the library sharp are not being met.

node ➜ /workspaces/langchainjs (fix/devcontainer) $ npm ls sharp
npm notice 
npm notice New minor version of npm available! 10.5.2 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice Run npm install -g npm@10.8.1 to update!
npm notice 
langchainjs@0.0.4 /workspaces/langchainjs
└─┬ @langchain/community@0.2.16 invalid: "workspace:*" from libs/langchain-anthropic -> ./libs/langchain-community
  └─┬ @xenova/transformers@2.5.4
    └── sharp@0.32.4

Searching in the library repo, I found this https://github.com/lovell/sharp/pull/3937, indicating that node 20.2.x is not supported (currently in use by the devcontainer image)

node ➜ /workspaces/langchainjs (main) $ node -v
v20.2.0

But that is not the cause of this problem.

From the documentation of the sharp lib https://sharp.pixelplumbing.com/install#cross-platform :

When the cross-target is Linux, the C standard library must be specified.

And that seems to be the problem.

I've updated the devcontainer version so we can have a node > 20.2.x and included the libc into the .yarnrc.yml file in this branch of a fork https://github.com/langchain-ai/langchainjs/compare/main...lamoglia:langchainjs:fix/devcontainer and the yarn install finished ok

➤ YN0000: └ Completed in 0s 419ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 1s 5ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 1s 265ms
➤ YN0000: Done with warnings in 3s 121ms
jacoblee93 commented 5 days ago

Thank you for looking into this @lamoglia - could you make a PR with that?

I wonder if we can avoid building community by default... that would solve a fair number of dependency-related isseus I think

lamoglia commented 5 days ago

Sure, PR created.