langchain-ai / langchainjs

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

Punycode deprecated message #3284

Closed nickworks closed 4 months ago

nickworks commented 7 months ago

I keep getting a "[DEP0040] Deprecation Warning: The punycode module is deprecated." Is there a way I can fix this?

File:

// demo.js
import { LLMChain } from "langchain/chains";

CLI:

node --trace-deprecation demo.js

Error:

(node:4804) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
    at loadBuiltinModule (node:internal/modules/helpers:101:7)
    at Module._load (node:internal/modules/cjs/loader:1001:17)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/nick/projects/ai/langchain-cookbook/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
dosubot[bot] commented 7 months ago

🤖

Hello @nickworks! I'm Dosu, a friendly bot here to help you with your issues, answer any questions, and guide you in contributing to the langchainjs repository. While we're waiting for a human maintainer, I'm here to assist you. I'm currently looking into the issue you posted and will provide a more detailed response shortly.

dosubot[bot] commented 7 months ago

🤖

From the error message, it seems like the punycode module, which is deprecated, is being used somewhere in your project or its dependencies. However, it's not clear from the provided information where exactly this is happening.

To help you better, could you please provide more information? Specifically, it would be helpful to know:

  1. The version of Node.js you're using.
  2. The version of langchainjs you're using.
  3. If you have any other dependencies in your project, and if so, what they are and their versions.

This information will help me understand the context better and provide a more accurate solution.


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.

nickworks commented 7 months ago

I'm using Node v21.1.0 (according to node -v) I'm using Langchain 0.0.186 (according to package-lock.json)

In package.json, I have the following dependencies:

"dependencies": {
    "@tensorflow-models/universal-sentence-encoder": "^1.3.3",
    "@tensorflow/tfjs-converter": "^3.6.0",
    "@tensorflow/tfjs-core": "^3.6.0",
    "@tensorflow/tfjs-node": "^4.10.0",
    "cheerio": "^1.0.0-rc.12",
    "langchain": "^0.0.186"
  }
dosubot[bot] commented 4 months ago

Hi, @nickworks,

I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, you reported a deprecation warning for the punycode module, suggesting the use of a userland alternative. You provided details about the Node.js and langchainjs versions, as well as the project's dependencies.

Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and cooperation.

bakertn commented 3 months ago

I am getting the same issue. Vanilla getting started code from your lanchain getting started docs. No direct mention of punycode.
node v21.7.0 Just installed langchain js TODAY. Latest version. Also ran npm update. Completely up to date.

(base) PS C:\Users\lbake\VSCode Projects\langchainjs> node --trace-deprecation app.js (node:4792) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. at node:punycode:3:9 at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7) at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10) at loadBuiltinModule (node:internal/modules/helpers:104:7) at Module._load (node:internal/modules/cjs/loader:999:17) at Module.require (node:internal/modules/cjs/loader:1230:19) at require (node:internal/modules/helpers:179:18) at Object. (C:\Users\lbake\VSCode Projects\langchainjs\node_modules\whatwg-url\lib\url-state-machine.js:2:18) at Module._compile (node:internal/modules/cjs/loader:1368:14) at Module._extensions..js (node:internal/modules/cjs/loader:1426:10) Why did the ice cream cone go to therapy? Because it had too many toppings!

Then ran this to check the whatwg-url

(base) PS C:\Users\lbake\VSCode Projects\langchainjs> npm list whatwg-url your-package-name@1.0.0 C:\Users\lbake\VSCode Projects\LangChainJS └─┬ @langchain/openai@0.0.18 └─┬ openai@4.28.4 └─┬ node-fetch@2.7.0 └── whatwg-url@5.0.0

  This is the getting started code I am executing

import { ChatOpenAI } from "@langchain/openai"; import { ChatPromptTemplate } from "@langchain/core/prompts"; import { StringOutputParser } from "@langchain/core/output_parsers";

const prompt = ChatPromptTemplate.fromMessages([ ["human", "Tell me a short joke about {topic}"], ]); const model = new ChatOpenAI({}); const outputParser = new StringOutputParser();

const chain = prompt.pipe(model).pipe(outputParser);

const response = await chain.invoke({ topic: "ice cream", }); console.log(response); /* Why did the ice cream go to the gym? Because it wanted to get a little "cone"ditioning! /

So I echo the previous post.  Why is there a deprecated library in this project.  Please fix ASAP.  Extremely annoying.  

New install of everything, NODE, LangChain, today.   All new.  So this is a "current" issue.