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
npm
topnpm
. After extensive experience with both package managers, I believepnpm
offers 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
pnpm
achieves dramatically faster installation times through its innovative approach:pnpm
creates hard links from a global store rather than copying filesReal-world impact:
install
commands 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,
npm
stores 100 copies, whilepnpm
stores 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.json
but 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:
express
removescookie-parser
in a future version, your code won't mysteriously break4. Superior Monorepo Support
pnpm
was designed with monorepos in mind:Example commands:
Pros and Cons Analysis
Pros ✅
npm
commandsCons ❌
Migration Overhead
Compatibility Considerations
node_modules
structurepackage-lock.json
need updatesLearning Curve
npm
topnpm
Strictness
Windows-Specific Challenges
Windows Solutions:
pnpm
git config --system core.longpaths true
and enable in Windows registryComparison with Alternatives
Why not stay with
npm
?npm
v7+ added workspaces, it remains slower and more disk-intensiveWhy not Yarn?
pnpm
is faster and more disk-efficient than Yarnnode_modules
Bun compatibility
pnpm
works perfectly with Bun runtimepnpm
Bottom Line
The migration to
pnpm
represents 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,
pnpm
offers 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