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

Cannot install langchain package using npm: TypeError: Cannot read properties of null (reading 'edgesOut') #6792

Closed
5 tasks done
kareldonk opened this issue Sep 14, 2024 · 19 comments · Fixed by #6797
Closed
5 tasks done
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@kareldonk
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

None

Error Message and Stack Trace (if applicable)

npm http fetch GET 200 https://registry.npmjs.org/youtubei.js 6ms (cache hit)
npm verbose stack TypeError: Cannot read properties of null (reading 'edgesOut')
npm verbose stack at #loadPeerSet (C:\Program Files\nodejs\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:1286:38)
npm verbose stack at async #buildDepStep (C:\Program Files\nodejs\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:901:11)
npm verbose stack at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7)
npm verbose stack at async Promise.all (index 1)
npm verbose stack at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\reify.js:131:5)
npm verbose stack at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:150:5)
npm verbose stack at async Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:207:9)
npm verbose stack at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:74:5)
npm error Cannot read properties of null (reading 'edgesOut')
npm verbose cwd C:\Dev\test
npm verbose os Windows_NT 10.0.19045
npm verbose node v20.17.0
npm verbose npm v10.8.2
npm notice

Description

In a new node.js project with no dependencies, I try to install langchain using the following command:

npm i langchain

Then I eventually get the following error:

npm http fetch GET 200 https://registry.npmjs.org/youtubei.js 6ms (cache hit)
npm verbose stack TypeError: Cannot read properties of null (reading 'edgesOut')
npm verbose stack     at #loadPeerSet (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1286:38)
npm verbose stack     at async #buildDepStep (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:901:11)
npm verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7)
npm verbose stack     at async Promise.all (index 1)
npm verbose stack     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
npm verbose stack     at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:150:5)
npm verbose stack     at async Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:207:9)
npm verbose stack     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:74:5)
npm error Cannot read properties of null (reading 'edgesOut')
npm verbose cwd C:\Dev\test
npm verbose os Windows_NT 10.0.19045
npm verbose node v20.17.0
npm verbose npm  v10.8.2
npm notice

System Info

Windows_NT 10.0.19045
node v20.17.0
npm v10.8.2

Copy link

dosubot bot commented Sep 14, 2024

I found a similar issue that might be related to the problem you're experiencing:

  1. npm error @langchain/community v3.0.0 "Cannot read properties of null (reading 'edgesOut')" (closed)

    • Solution:
      • Ensure you are using the latest versions of npm and Node.js.
      • Check for any conflicts with other dependencies in your project.
      • Try installing the package in a clean environment to rule out local issues.
      • Check the peer dependencies specified in the package.json of @langchain/community version 0.3.0 and later to identify any potential conflicts.
  2. Error on install since yesterday for cloudflare langchain (open)

    • Solution:
      • Check if the issue persists with the latest versions of these packages.
      • Ensure that there are no conflicts with other dependencies in your project.

To troubleshoot your issue, you can try the following steps:

  1. Update npm and Node.js:
    Ensure you are using the latest versions of npm and Node.js. You are already using Node.js v20.17.0 and npm v10.8.2, which are recent versions, so this step might not be necessary.

  2. Check for Dependency Conflicts:
    Since you mentioned this is a new project with no dependencies, this step might not be relevant. However, if you have any global npm packages that might conflict, consider checking them.

  3. Install in a Clean Environment:
    Create a new project directory and try installing the langchain package again:

    mkdir new-project
    cd new-project
    npm init -y
    npm install langchain
  4. Check Peer Dependencies:
    Ensure that the peer dependencies specified in the package.json of the langchain package are compatible. Here are the peer dependencies for langchain:

    {
      "@langchain/anthropic": "*",
      "@langchain/aws": "*",
      "@langchain/cohere": "*",
      "@langchain/community": "*",
      "@langchain/core": ">=0.2.21 <0.4.0",
      "@langchain/google-genai": "*",
      "@langchain/google-vertexai": "*",
      "@langchain/groq": "*",
      "@langchain/mistralai": "*",
      "@langchain/ollama": "*",
      "axios": "*",
      "cheerio": "*",
      "handlebars": "^4.7.8",
      "peggy": "^3.0.2",
      "typeorm": "*"
    }

If the issue persists, you might want to follow the discussion in the related issues for any updates or additional solutions.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Sep 14, 2024
@kareldonk
Copy link
Author

#3 installing in clean environment does not help. neither do the other suggestions.

@BeRecursive22
Copy link

@kareldonk I tried to install it and been thrown same errors.

@kareldonk
Copy link
Author

For some reason adding the --legacy-peer-deps CLI argument makes it work.

npm i langchain --legacy-peer-deps

@WanielDeiss
Copy link

I get the same error, even with older langchain versions. I have the latest Node & NPM version and want to install it in a fresh project without other dependencies. Here is a screenshot.

image

Node: 22.8.0
NPM: 10.8.3
macOS Sonoma 14.2.1

@brianpursley
Copy link

Same problem here on Ubuntu 22.04.5.

I also tried a few previous npm versions with no success.

By the way, yarn add langchain works, so I guess this problem is specific to npm somehow.

@pablobesada
Copy link

pablobesada commented Sep 14, 2024

same problem here in multiple linux versions and MacOS

@BeRecursive22
Copy link

MacOs M1 Air

same problem. Not even able to navigate the code...it's freezing my terminal probably due to the size of the project.

@Valeriamelly
Copy link

@kareldonk true, I had the same error, then I tried your suggest
image
image

@danstarns
Copy link

+1

Error log:

833 verbose stack TypeError: Cannot read properties of null (reading 'edgesOut')
833 verbose stack     at #loadPeerSet (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1286:38)
833 verbose stack     at async #buildDepStep (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:901:11)
833 verbose stack     at async Arborist.buildIdealTree (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:181:7)
833 verbose stack     at async Promise.all (index 1)
833 verbose stack     at async Arborist.reify (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
833 verbose stack     at async Install.exec (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/lib/commands/install.js:150:5)
833 verbose stack     at async Npm.exec (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/lib/npm.js:207:9)
833 verbose stack     at async module.exports (/Users/danielstarns/.nvm/versions/node/v22.4.1/lib/node_modules/npm/lib/cli/entry.js:74:5)
834 error Cannot read properties of null (reading 'edgesOut')

Running with --legacy-peer works:

npm i langchain --legacy-peer-deps

@jacoblee93
Copy link
Collaborator

Hey folks, looking into this - this is quite odd!

@jacoblee93
Copy link
Collaborator

So I initially thought this was related to 0.3.0, but I can run:

$ npm i @langchain/core@0.1.28

But not:

$ npm i @langchain/core@0.1.29

Investigating why this suddenly started failing...

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Sep 15, 2024

Ok, it seems npm changed something with how they handle peer dependencies internally - we have a circular peer dependency in a subpackage on @langchain/core, and hard-locking it to a version before the circular peer dep works.

As a workaround, try @danstarns' comment:

npm i langchain --legacy-peer-deps

Or switch to yarn/pnpm. Will continue to work towards a resolution here.

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Sep 15, 2024

Hey folks, have just cut @langchain/core@0.3.1 and langchain@0.3.2 - can you try again and let me know if that fixes it?

I'll also cut new 0.2 versions of the above packages shortly in case you don't want to update to latest.

@tro9999
Copy link

tro9999 commented Sep 15, 2024

clean install 0.3.2 works ok

@WanielDeiss
Copy link

Hey folks, have just cut @langchain/core@0.3.1 and langchain@0.3.2 - can you try again and let me know if that fixes it?

I'll also cut new 0.2 versions of the above packages shortly in case you don't want to update to latest.

works for me now! thanks

@danstarns
Copy link

Fixed in 0.3.2. Thanks @jacoblee93 <3

@jacoblee93
Copy link
Collaborator

Thanks for reporting all! This was a super bizarre coincidence with 0.3.

@Valeriamelly
Copy link

It works too. Thankss @jacoblee93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants