Replies: 95 comments 11 replies
-
Duplicate of #9161 |
Beta Was this translation helpful? Give feedback.
-
Maybe we could unlock #9161? It's frozen I can't upvote the issue. This way, you could gather more feedback from the community. |
Beta Was this translation helpful? Give feedback.
-
/CC @nodejs/user-feedback |
Beta Was this translation helpful? Give feedback.
-
Well, looking at https://stats.yarnpkg.com/, yarn accounts for 0.02% of the downloads, it's probably too early. |
Beta Was this translation helpful? Give feedback.
-
It became impossible for us to get stats since npm moved to Cloudflare, circa ~june 2018. Back then, Yarn had 48% of the package downloads, in constant augmentation from ~20% in April 2017. Your guess is as good as mine as to where we are now 🙂 |
Beta Was this translation helpful? Give feedback.
-
I would like to get this re-opened because of the reason that alternatives become more popular and are faster than npm (besides all that was mentioned in the #9161 discussion). The title should be
|
Beta Was this translation helpful? Give feedback.
-
I would definitely champion work in this direction. There are a couple important bits:
|
Beta Was this translation helpful? Give feedback.
-
I am in favor of a user-selectable package manager, with the default one that is:
than others. In addition, visible evidence of / promise on:
|
Beta Was this translation helpful? Give feedback.
-
re-opening, as the linked issue (to which this is a duplicate of) is closed and locked. |
Beta Was this translation helpful? Give feedback.
-
One important question that we should first agree on is: what workflow do we want to improve? There are two different ones, and the solutions aren't the same for both.
The difference may look subtle but let me show a practical example. VSCode uses Yarn as package manager (they have a For this reason, I'm not convinced by, let's say, an install prompt that would allow choosing the package manager to install. In my mind, it'll simply fall into the same trap of making it harder to work with the package managers that didn't get picked. It may help new users a bit, but power users will end up still needing to install the other package managers manually. So what do I suggest? I obviously really want to solve this. First, to summarize my ideal solution:
Before going further, let me tell you about a feature of Yarn, something called So .. what's my point? Simple: this workflow proves that we don't need the full package managers to be shipped within Node. What we do need are the binary names to be shipped with Node. For example for Yarn, all we really need is for a global
And it's not Yarn-specific! Generally speaking, all we need is to mock the package managers binaries to "jumpers" - very simple binaries that would throw an error if the version they detect should be used isn't installed. For example, here are a few examples of the workflow I have in mind:
|
Beta Was this translation helpful? Give feedback.
-
I like your proposal. However, the user still has to know the appropriate CLI command for the package.json's engine/pm field. What if we had a generic command for that aswell, e.g.: node packages install
# checks package.json, installs pm engine if not available, uses it to install deps |
Beta Was this translation helpful? Give feedback.
-
There are a few ways we could solve it. For example, we could simply make the jumpers warn when used on incompatible projects:
This way each project would keep their identity, and users wouldn't be confused as much by a command having different behaviors on different projects (my main worry with having a single command). |
Beta Was this translation helpful? Give feedback.
-
LGTM @arcanis ! What about global installed packages? Some prefer npm, some prefer yarn and if both are used, incompatibilities could appear (had this issue with NVM, NPM and pnpm). To your suggestion I would add this: Users can select a default package manager, this would be picked by default for global packages and newly created projects. For example, when I create a new project I now do Additionally, I would cache and symlink the PM versions, so the user is not downloading duplicated versions, when they already got the same in another project. |
Beta Was this translation helpful? Give feedback.
-
While aliases might be useful in the future, I think this should be a follow-up and considered out-of-scope for this discussion. Multiple reasons for that:
I'd prefer we stay focused on global binaries, and later on we'll have the time to think about a Node integration - in a separate project dedicated to this goal. |
Beta Was this translation helpful? Give feedback.
-
I have two follow-ups on @arcanis’s proposal:
Looking into the future I see exponential growth of projects that are added to this, leading to a more fractured ecosystem and overall worse DX for new and novice users. I am extremely cautious about shoving this burden on users. Additionally, to both @jasnell and @arcanis, how do you envision your potential solutions being effective for FaaS platforms, Docker images, and PaaS platforms without tremendous additional overhead? (I am aware that this has been a request from FaaS folks who are running code that doesn’t need npm!) |
Beta Was this translation helpful? Give feedback.
-
Another idea that I think wasn't mentioned. Maybe it needs to be a package manager manager + node manager. Maybe it should be done on the nvm/nvs level as different projects are also expecting a specific version of Node, not only a specific version of the package manager.
I think it is less about developing packages and more about developing large enterprise projects. Small package authors don't really care about which package manager they use. Large projects might need specific features of specific package managers. |
Beta Was this translation helpful? Give feedback.
-
@arcanis ... that's awesome. Give me about a day to have time to check out your POC then get back to you on it. @devsnek ... I definitely agree with what you're saying but currently, it's just not clear who actually owns the definition of How a Node.js Module Actually Works. I think we need to put some thought in to addressing that. |
Beta Was this translation helpful? Give feedback.
-
I would be highly in favor of having stubs that install them on demand. |
Beta Was this translation helpful? Give feedback.
-
I read the entire thread and first of all I'm thankful, that this discussion has started because I think it is really important to have this discussed. To give my two cents to this discussion: |
Beta Was this translation helpful? Give feedback.
-
How about no package manager at all like both Deno and browser handle it? With absolute http urls! Obvious we would need more security options like disable/sandboxing fs, net, process & env |
Beta Was this translation helpful? Give feedback.
-
What is Deno's story for versioning? How do you distinguish SemVer major/minor/patch bumps? How do you express a peer dependency relationship? |
Beta Was this translation helpful? Give feedback.
-
Also, suppose:
How would Deno ensure that a single copy of |
Beta Was this translation helpful? Give feedback.
-
That can be handled by some CDN servers url structure Googles Hosted Libraries have done it even since before node's was introduced Import maps is also possible in deno that can help with dependencies |
Beta Was this translation helpful? Give feedback.
-
There's a pretty fundamental difference between tink and pnp, afaik. Tink does not change or override the Node.js module resolution process. Instead, it creates a virtual filesystem, such that the Node.js module resolver just works like it always has. When it gets We fully appreciate that enterprise (or other) users may prefer to install without this kind of experimental magic. When we do implement it (which won't be for a while yet), it'll be opt-in for at least one major release, and assuming all goes well, opt-out thereafter. We have no plans to ever ship a version of npm that can't install your dependencies right into node_modules as normal files, and may back away from this entire endeavor if it turns out to be a bad idea in practice. npm is at least as committed to backwards compatibility as Node.js, even to a fault. And we're of course happy to keep the lines of communication open and make sure we're on the same page about the DX that npm and Node.js provide for our users. |
Beta Was this translation helpful? Give feedback.
-
The biggest difference is that tink is dead. |
Beta Was this translation helpful? Give feedback.
-
For the time being this is available, and you can add this to your package.json to stop the wrong manager from being used: {
"scripts": {
"preinstall": "npx -y only-allow pnpm" // for example
}
} But this only has (according to the readme) npm, pnpm, and yarn options, and I see this as more of a hack. (and npx is used, lol) I think I am for the stub / choose in installer option. If these don't work, honestly I think the current bundling of npm is fine, since you can install all other managers once you have one.
@jasnell haha yea |
Beta Was this translation helpful? Give feedback.
-
another thing: a package manager is a package manager manager since a package manager is just a package. and I dont think we need a dedicated package manager manager |
Beta Was this translation helpful? Give feedback.
-
I created this issue over 3 years ago, when Yarn still had a strong advantage over NPM in several respects. Since then, NPM has come a very long way (especially with the release of v7) and I personally no longer support this motion. |
Beta Was this translation helpful? Give feedback.
-
npm still doesn't support resolutions which are GOLDEN for addressing security vulns and other problems. IDK how people live without it. It's okay. npm will get around to it in a couple years. Along with PNP, |
Beta Was this translation helpful? Give feedback.
-
Yarn has had its first major release [1], and I think it should be taken under serious consideration as a de-facto replacement for NPM as the default package manager.
Yarn is compatible with NPM while being much more performant. It also supports a wide array of features and is under active and rapid development. It has great traction in the community, with almost 200k repos on GitHub using it to some extent. Defaulting to it will likely be beneficial both to the community and the Node ecosystem at large.
[1] https://code.facebook.com/posts/274518539716230
Beta Was this translation helpful? Give feedback.
All reactions