langchain-ai / langchainjs

πŸ¦œπŸ”— Build context-aware reasoning applications πŸ¦œπŸ”—
https://js.langchain.com/docs/
MIT License
12.16k stars 2.05k forks source link

Build Error Railway #2544

Closed Santy1422 closed 11 months ago

Santy1422 commented 11 months ago

Hello everyone, until last night my deploy in railway was working perfectly. Since today I have a problem with the dependencies that it cannot find. It works locally but when I build railway it gives me this error. I have tried changing versions, npm and --force and there is no way for railway to install the dependencies. `#8 [stage-0 4/9] RUN nix-env -if .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix && nix-collect-garbage -d

8 CACHED

9 [stage-0 5/9] RUN apt-get update && apt-get install -y --no-install-recommends fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libgbm1 libgtk-3-0 libnspr4 libnss3 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxrandr2 libxss1 libxtst6 xdg-utils

9 CACHED

10 [stage-0 6/9] COPY . /app/.

10 DONE 0.0s

11 [stage-0 7/9] RUN --mount=type=cache,id=s/dfd50128-8f82-49b3-8027-d822efec870c-/root/npm,target=/root/.npm npm i

11 0.713 npm WARN config production Use --omit=dev instead.

11 23.28 npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

11 23.29 npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated

11 23.29 npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated

11 23.38 npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated

11 26.35 npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

11 26.86 npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added

11 34.84 npm WARN deprecated puppeteer@13.7.0: < 19.4.0 is no longer supported

11 45.17

11 45.17 > whatsapp-botgpt@1.0.0 postinstall

11 45.17 > npm run tsc

11 45.17

11 53.49 src/databases/pinecone/embedPDFs.ts(4,26): error TS2307: Cannot find module 'langchain/document' or its corresponding type declarations.

11 53.49 src/databases/pinecone/embedPDFs.ts(5,34): error TS2307: Cannot find module 'langchain/embeddings/openai' or its corresponding type declarations.

11 53.49 src/databases/pinecone/embedPDFs.ts(6,48): error TS2307: Cannot find module 'langchain/text_splitter' or its corresponding type declarations.

11 53.49 src/databases/pinecone/envedText.ts(1,34): error TS2307: Cannot find module 'langchain/embeddings/openai' or its corresponding type declarations.

11 53.49 src/databases/pinecone/envedText.ts(2,48): error TS2307: Cannot find module 'langchain/text_splitter' or its corresponding type declarations.

11 53.56 npm ERR! code 2

11 53.56 npm ERR! path /app

11 53.57 npm ERR! command failed

11 53.57 npm ERR! command sh -c -- npm run tsc

11 53.57

11 53.57 npm ERR! A complete log of this run can be found in:

11 53.57 npm ERR! /root/.npm/_logs/2023-09-06T18_46_13_333Z-debug-0.log

11 ERROR: process "/bin/bash -ol pipefail -c npm i" did not complete successfully: exit code: 2


[stage-0 7/9] RUN --mount=type=cache,id=s/dfd50128-8f82-49b3-8027-d822efec870c-/root/npm,target=/root/.npm npm i:

53.49 src/databases/pinecone/embedPDFs.ts(6,48): error TS2307: Cannot find module 'langchain/text_splitter' or its corresponding type declarations.

53.49 src/databases/pinecone/envedText.ts(1,34): error TS2307: Cannot find module 'langchain/embeddings/openai' or its corresponding type declarations.

53.49 src/databases/pinecone/envedText.ts(2,48): error TS2307: Cannot find module 'langchain/text_splitter' or its corresponding type declarations.

53.56 npm ERR! code 2

53.56 npm ERR! path /app

53.57 npm ERR! command failed

53.57 npm ERR! command sh -c -- npm run tsc

53.57

53.57 npm ERR! A complete log of this run can be found in:

53.57 npm ERR! /root/.npm/_logs/2023-09-06T18_46_13_333Z-debug-0.log


Dockerfile:20


18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH

19 | COPY . /app/.

20 | >>> RUN --mount=type=cache,id=s/dfd50128-8f82-49b3-8027-d822efec870c-/root/npm,target=/root/.npm npm i

21 |

22 | # build phase


ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm i" did not complete successfully: exit code: 2

Error: Docker build failed`

dosubot[bot] commented 11 months ago

πŸ€–

Hello,

From the error logs you've shared, it seems like the Railway build is unable to find the 'langchain/document', 'langchain/embeddings/openai', and 'langchain/text_splitter' modules. This could be due to a few reasons:

  1. Incorrect Import Paths: Ensure that the import paths in your files are correct. The paths should be relative to the file in which they are being imported. If the paths are correct locally but not on the Railway build, it could be due to differences in the file structure between your local environment and the Railway environment.

  2. Deprecation of Imports: As per the warning message in your 'langchain/src/retrievers/index.ts' file, importing from 'langchain/retrievers' is deprecated and you should import from 'langchain/retrievers/remote' or other specific retrievers instead. Please refer to the upgrade instructions at https://js.langchain.com/docs/getting-started/install#updating-from-0052 to update your imports accordingly.

  3. Version Mismatch: The version of LangChain being used in your project is "0.0.4". However, the latest version of LangChain is "0.0.144". It's possible that the modules you're trying to import have been added or moved in a later version. You might want to consider updating your LangChain version to the latest one.

  4. Node Modules Not Installed: The error could also be due to the node modules not being installed correctly in the Railway environment. You could try clearing the Railway build cache and rebuilding the project.

If none of these solutions work, could you please provide more information about your project setup? Specifically, it would be helpful to know more about your file structure and how you're importing the 'langchain/document', 'langchain/embeddings/openai', and 'langchain/text_splitter' modules in your files.

Best, Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Santy1422 commented 11 months ago

@dosu_bot atacch my packet json and imports

{ "name": "whatsapp-botgpt", "version": "1.0.0", "description": "Chat de whatsapp bot", "main": "index.js", "directories": { "doc": "docs", "test": "test" }, "engines": { "node": "v18.12.1" }, "scripts": { "test": "jest --detectOpenHandles", "postinstall": "npm run tsc", "tsc": "tsc", "dev": "ts-node-dev --respawn --pretty --transpile-only src/index.ts", "start": "npm run tsc && NODE_ENV=PRODUCTION node build/index.js", "lint": "eslint src/**/*.js --fix" }, "keywords": [], "author": "", "license": "ISC", "bugs": { "url": "https://github.com/Santy1422/WhatsappBot/issues" }, "homepage": "https://github.com/Santy1422/WhatsappBot", "devDependencies": { "@types/bcrypt": "^5.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/multer": "^1.4.7", "@types/node": "^20.4.1", "@types/validator": "^13.7.17", "@types/xml2js": "^0.4.11", "@typescript-eslint/parser": "^5.61.0", "eslint": "^7.9.0", "eslint-config-airbnb": "^18.2.0", "eslint-config-airbnb-base": "^14.2.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-prettier": "^3.1.4", "jest": "^26.4.2", "nodemon": "^2.0.4", "prettier": "^2.1.2", "ts-node": "^10.9.1", "ts-node-dev": "^2.0.0", "typescript": "^5.1.6" }, "dependencies": { "@pinecone-database/pinecone": "^0.1.6", "async": "^3.2.4", "axios": "^1.3.0", "axios-rate-limit": "^1.3.0", "bcrypt": "^5.1.0", "body-parser": "^1.20.2", "cors": "^2.8.5", "dotenv": "^8.6.0", "express": "^4.18.2", "express-jwt": "^8.3.0", "express-openid-connect": "^2.11.0", "express-rate-limit": "^6.7.0", "firebase-admin": "^11.9.0", "fs": "^0.0.1-security", "jsonwebtoken": "^9.0.0", "jwks-rsa": "^3.0.1", "mongodb": "^5.2.0", "mongoose": "^6.11.3", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", "path": "^0.12.7", "pdf-parse": "^1.1.1", "qrcode-terminal": "^0.12.0", "stripe": "^13.4.0", "uuid": "^9.0.0", "validator": "^13.7.0", "whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7", "wwebjs-mongo": "^1.1.0" }, "peerDependencies": { "mongodb": "^5.2.0" }, "prettier": { "printWidth": 900, "semi": true, "singleQuote": true, "trailingComma": "es5" } } Imports: import { OpenAIEmbeddings } from "langchain/embeddings/openai"; import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; import { pineIndex } from "./init"; import { OPENAI_API_KEY } from "../../config/env"; import { OpenAIEmbeddings } from "langchain/embeddings/openai"; import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; import { pineIndex } from "./init"; import { OPENAI_API_KEY } from "../../config/env";const { OpenAIEmbeddings } = require('langchain/embeddings/openai') const { RecursiveCharacterTextSplitter } = require('langchain/text_splitter') import { OpenAI } from "langchain/llms/openai"; import {loadQAStuffChain} from "langchain/chains"; const { Document } = require('langchain/document') import { pineIndex } from './init' import { QueryResponse, ScoredVector } from '@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch' import { OPENAI_API_KEY } from '../../config/env'import { PineconeClient } from "@pinecone-database/pinecone"; import { PINECONE_API_KEY, PINECONE_ENVIRONMENT, PINECONE_INDEX_NAME } from "../../config/env"; import { VectorOperationsApi } from "@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch";

dosubot[bot] commented 11 months ago

πŸ€–

Hello,

From the error logs you've shared, it seems like the Railway build process is unable to find the 'langchain' modules. This could be due to a few reasons:

  1. The 'langchain' package is not installed in the Railway environment. This could happen if the 'langchain' package is not listed in the 'dependencies' section of your package.json file. However, based on the context provided, it seems like the 'langchain' package is indeed listed under the "dependencies" section of your package.json file.

  2. The 'langchain' package is not correctly installed in your local environment. This could be the case if there are issues with your local npm or node setup. However, you've mentioned that this issue doesn't occur in your local environment, which suggests that your local setup is likely correct.

Given these points, I would suggest trying the following steps:

  1. Ensure that the 'langchain' package is correctly listed in the 'dependencies' section of your package.json file. It should be listed as follows:
"dependencies": {
  "langchain": "^0.0.144"
}
  1. Try clearing the Railway build cache. Sometimes, cached data from previous builds can interfere with the current build process. You can clear the build cache from the Railway dashboard.

  2. If the issue persists, try recreating the app on Railway. According to a similar issue in the LangChain repository (unable to import {OpenAIEmbeddings}), this approach helped resolve the issue.

If none of these steps work, please provide more information about your Railway setup and we can investigate further.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

jacoblee93 commented 11 months ago

Is this building with npm install by any chance? There was a peer dependency issue yarn was ignoring that will be resolved shortly in the next release.

jacoblee93 commented 11 months ago

Hey @Santy1422, I've just published 0.0.145 which should fix this but please let me know if it emerges again.