Replies: 3 comments 2 replies
-
|
Here is the timing from a fresh install with all
This should resolve our recurring CI issues where builds randomly fail due to missing peer dependencies. With npm, these dependencies unpredictably appear as unmet requirements even though they should already be available through the dependency tree. Why this keeps happening with npm (and why pnpm fixes it): npm's flat node_modules structure creates "phantom dependencies" - packages can accidentally access dependencies they didn't explicitly declare. This works on one developer's machine but breaks in CI or on another teammate's setup. The same package.json can even produce different node_modules structures depending on installation order or npm version. pnpm solves this through:
|
Beta Was this translation helpful? Give feedback.
-
It would be good to see how exactly your team is installing/building, so I can compare with |
Beta Was this translation helpful? Give feedback.
-
|
Just documenting what I've done for this. I created this PR to help with this before making this change. But it was denied due to some big changes that are in flux, but hopefully once those are ironed out we can revisit this. It alleviates most of the major problems when it comes to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'd like to propose migrating LibreChat from
npmtopnpm. After extensive experience with both package managers, I believepnpmoffers significant advantages that align perfectly with our project's needs, particularly for our monorepo structure. The migration effort is minimal, while the benefits - faster installations, massive disk savings, and stricter dependency management - are substantial and ongoing.Why pnpm?
1. Performance: 2-3× Faster Installations
pnpmachieves dramatically faster installation times through its innovative approach:pnpmcreates hard links from a global store rather than copying filesReal-world impact:
installcommands during development2. Disk Space: Up to 50% Savings
pnpm's content-addressable storage system revolutionizes how packages are stored:Example: If 100 projects use React 18.2.0,
npmstores 100 copies, whilepnpmstores it once and creates 100 hard links.3. Dependency Isolation: Preventing "Phantom Dependencies"
What are Phantom Dependencies?
Phantom dependencies occur when your code imports packages that aren't explicitly listed in
package.jsonbut happen to be installed by other dependencies.Real example from LibreChat:
https://github.com/danny-avila/LibreChat/blob/main/api/cache/keyvMongo.js#L4
Another example:
http://github.com/danny-avila/LibreChat/blob/main/api/server/services/Files/Audio/STTService.js#L3
Why this matters:
expressremovescookie-parserin a future version, your code won't mysteriously break4. Superior Monorepo Support
pnpmwas designed with monorepos in mind:Example commands:
Pros and Cons Analysis
Pros ✅
npmcommandsCons ❌
Migration Overhead
Compatibility Considerations
node_modulesstructurepackage-lock.jsonneed updatesLearning Curve
npmtopnpmStrictness
Windows-Specific Challenges
Windows Solutions:
pnpmgit config --system core.longpaths trueand enable in Windows registryComparison with Alternatives
Why not stay with
npm?npmv7+ added workspaces, it remains slower and more disk-intensiveWhy not Yarn?
pnpmis faster and more disk-efficient than Yarnnode_modulesBun compatibility
pnpmworks perfectly with Bun runtimepnpmBottom Line
The migration to
pnpmrepresents a strategic investment in our development infrastructure. While there's a one-time migration cost, the ongoing benefits - faster builds, disk savings, and improved dependency management - make this a compelling upgrade for LibreChat's monorepo architecture.The strict dependency isolation alone will prevent numerous "works on my machine" issues and improve our code quality. Combined with the performance improvements and disk savings,
pnpmoffers a modern, efficient solution for our package management needs.I'm happy to address any questions or concerns about this proposal. What are your thoughts on making this transition?
Beta Was this translation helpful? Give feedback.
All reactions