I have some symlinks in node_modules
that come from another custom tool. Yarn likes to blow them away:
> ll | grep "\.js"
gen-await.js -> ../modules/node-utils/build/gen-await.js
> yarn
...
> ll | grep "\.js"
I have some symlinks in node_modules
that come from another custom tool. Yarn likes to blow them away:
> ll | grep "\.js"
gen-await.js -> ../modules/node-utils/build/gen-await.js
> yarn
...
> ll | grep "\.js"
Comments are closed.
Copyright © 2021 Fantas...hit
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
yarn deletes all files and directories under node_modules that don’t belong to the currently installed packages. This is part of the design. It does work differently than npm’s pruning/cleaning of extraneous files.
For comparison, npm will only delete extraneous directories in
node_modules
if they have apackage.json
file. It won’t remove other non-package directories. It also just never cleans anything out ofnode_modules/.bin
. Evennpm prune
doesn’t remove them.My personal opinion is that npm is incorrect.
node_modules
is the directory for the package manager to manage and no manual modifications should be made. I could be convinced otherwise though.@yarnpkg/core think this should be “closed / as designed” or a bug due to “npm compatibility”?
Yes it would, and probably should. If something doesn’t match the package manager expected output, it should be removed, otherwise the guarantee that
yarn install
is all that’s needed to get the exact same node_modules layout anywhere doesn’t hold.No, it should fail the installation. If something causes a package not to be installed (such as an unknown protocol), the whole installation is bogus, since the requested dependencies won’t be there, breaking the contract.
If you want to use custom protocols, then put them in another key than
dependencies
.They shouldn’t exist in the first place🙂
@arcanis — This goes back to my point that node owns
node_modules
, not the package manager, or at least not any one package manager. There’s absolutely no reason or benefit for yarn to aggressively prune things from this folder that it clearly doesn’t own since it has no way to create them.Sure, except that yarn would still delete the files generated. Not having an escape hatch seems unnecessarily controlling.
@rally25rs Not arguing with a point, that
yarn install
is cleaning all symlinks and directories inside node_modules, I have another problem here.If there is a symlink in a node_modules, that leads to an external directory,
yarn install
is following it and purging also an external content. Don’t you think, that behavior should be just unlinking a symlink instead of following it?it’s an npm scope, in which case we have to recurse inside to find out the
actual package folders. So from Yarn point of view, @/sources is a package
called “sources” from the scope “@”.
Three solutions :
– special case “@” in Yarn
– don’t recurse if the scope folder is a symlink
– ask users not to create such symlinks
…
@arcanis <https://github.com/arcanis>, I created a repo
<https://github.com/shvar/yarn-install> for my case and found an
interesting thing.
I wrote a steps for reproducing in README, but in short, the problem can😕
be observed if and only if the name of symlink starts with @. Sounds like
some internal policy, that we missed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5709 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA_WaxSv6NmqENQ_L4P-siGWFtdjHVoaks5uhHSOgaJpZM4TeVlF>
.
I haven’t had time to work on this yet, but would be interested to merge a fix – would someone be interested to contribute it? I could review and merge it in time for the next release🙂
What about regular symlinks like I said before? I don’t use
@
.I’m in this same situation — I need to have a symlink in my
node_modules
and I don’t want yarn to delete it. My use case is I have a private copy of a package (pkgA) checked out as a git submodule in$TOP/pkgA
; I’m working on both my main app and pkgA, so I want my build (and hot reload) to pick up changes in both. I’ve triedlink:
andworkspaces
but neither is helpful. Simple symlinknode_modules/pkgA -> ./pkgA
works perfectly, except that yarn deletes it! Could yarn just have an option for “known non-Yarn files in node_modules” that it just wouldn’t delete?