-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[BUG] npm install replaces links with downloaded modules #2372
Comments
In case this could be helpful for anyone, I was able to work around this issue by using cd /path/to/my-dependency
npm install && npm run build
cd /path/to/my-project
npm install /path/to/my-dependency
npm install |
we've made some changes with regards to how linked modules are handled, can you try updating to the latest release |
This should be reopen, the bug still not fixed (or maybe regressed) on npm 7.11.2 |
I agree this shouldn't have been closed, unless the issue had maybe been fixed and now it is showing up again as a regression. Anyway, this bug is not an intricate or difficult to reproduce one, at all; actually if anything it is pretty trivial to check. So much, that I'm surprised this is not having a bigger impact on lots of NPM users. Are we just using For future reference I'm adding here a complete set of example steps that can be followed to see the problem in action; these can be used at any future time to re-check if the problem persists. |
How to reproduceCheck versions:
Clone sample project
Create a link
Verify that the link has been created in global prefix
Make use of the link
Verify that the link has been used
Run any other install command. This step is what triggers the reported bug:
Verify if the link is still present (good), or if it has been replaced (bad)
|
npm link has never worked right. Most users have just given up on it. My biggest hope for npm 7 was the ability to finally use npm link, but I ended up here instead. |
afaik, since npm 5, this is how Any time you install something, you have to manually recreate all your links. |
It's not by design. The NPM team has talked about it before, and said npm 7 was going to fix it, but then it never was fixed:
The comment above was made three years ago... (The original post of the linked thread is not exactly the same issue -- it's about |
That there's tons of issues with it, and that the plan is to fix it, does not mean it wasn't originally by design. |
If this issue is on the npm dev team's radar, can we get an update on the roadmap/plan for its resolution?
Whichever of those three is the case, the lack of response on it is concerning, as it gives the impression that the dev team may not have the resources/motivation to maintain the command's functionality/reliability. I've been annoyed by this issue for enough months/years that I'm finally seriously considering switching to Yarn now (despite most of Yarn's previous advantages having been "caught up to" by npm). That today I learned about Yarn's plugin system (which NPM doesn't have an equivalent of, due partly to NPM's file-based hook scripts not working on Windows) has pushed me right to the edge. (I'm torn between NPM's ubiquity, and Yarn's solving of a few key "npm pain points".) A resolution would be ideal; but I'll settle for just a dev acknowledgement + discussion at this point! |
If this is still broken I would suggest opening a new ticket to have any chance of being noticed. |
That'd be a full-circle closure for this issue, I have to admit. A self-fulfilling prophecy where this report ends up joining the long trail of closed and/or forgotten others that are listed in the initial description. If anyone opens a new issue, it might be useful that the past reports research that I did was copied over too, so the full context doesn't get lost. Good luck with that, though; seems their policy is to close well documented reports (like this one) even if the issue is well known, trivial to reproduce, and regardless of whether it is actually fixed or not. I don't care any more to follow up with more reporting. |
@nlf @darcyclarke can we please re-open this issue? this is still present. i feel like the in-depth write-up of this ticket makes this extra-worthy of re-opening versus opening another ticket. |
Yet again, Note that not only does the library's working-directory get nuked -- literally everything inside the symlinked folder gets nuked, including the Beware of using (FWIW, I've since switched to using yarn for all my new projects; haven't converted everything to it yet though. For people annoyed by Yarn 2's inability to have user-specific symlinks, I made a Yarn plugin that adds support for this.) |
@Venryx WOAH really? This bug is about the links themselves being deleted. If npm is reaching through the link and deleting files inside the linked directory then please open a separate issue as that's incredibly serious and the npm team doesn't seem to be paying much attention to this one. |
Re: #2372 (comment) (et al) The issue with the link being removed on a subsequent As @j1elo mentioned, the workaround for this is to explicitly install a path with Another workaround is to set
@Venryx This is a different issue than the OP in this issue. Can you please open a new issue, and provide as much reproduction details as possible? At the very least, operating system and versions of npm and node in use. The best would be a minified reproduction case that shows the problem. That one has been reported a few times, and it's proven very tricky to track down, but it is possible that I'm about to fix it, since it seems like it might (in theory) match the pattern of another issue I'm working on. Thanks! |
@isaacs -- it sounds like there isn't a path forward for
I'm not a Node/npm engineer, but if I were designing this feature I'd want to persist |
FWIW, my suggestion on this issue would perhaps be to have a |
it's been 3 years and 3 new major versions, and this has AFAIK not been addressed. can we at least please reopen this? @isaacs |
I no longer work on npm, haven't for about three years now. Please don't ping me on these issues, I can't help you. |
---- EDIT 2021-05-10: Added how to reproduce in comment below.
npm install replaces link with downloaded module
Current Behavior
After running
npm link
, a symlink is created to the target dependency. Afterwards, othernpm
commands such asnpm install
will break the mentioned link:Expected Behavior
After running
npm link
, a symlink is created to the target dependency. Afterwards, othernpm
commands such asnpm install
don't alter the mentioned link:Description
For context, this is a well-known and long-standing bug that has been causing confusion to users and has been reported multiple times in the past. Here are some relevant or related reports:
npm install after npm link deletes linked module dependencies in it's node_modules folder #17287. Repo archived. Issue ignored. Closed without a fix, for a future overhaul on npm@7.
npm install
afternpm link
will "steal" dependencies from linked packages #10343. Repo archived. Issue ignored. Closed without a fix, for a future overhaul on npm@7.npm 5 dedupes even in linked modules #16788. Still open but repo archived.
Npm deletes stuff from linked module’s node_modules. Again, forums were archived.
Sometimes
npm install
deletes linked module, replaces it with downloaded module.Some of these reports were closed with the conclusion that the issue would definitely not be fixed in current versions (<= 6) of NPM, and instead a fix would be postponed for a future NPM v7, citing "an overhaul of how npm link works" and this RFC.
After bumping into this bug today, recollecting all this information, and updating my NPM version to 7.2.0, I was surprised to find that links are still lost when any further install operation is done after running
npm link
.So I guess the question is: was this really fixed with NPM 7 and is now a regression?
Environment:
The text was updated successfully, but these errors were encountered: