-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 removes linked packages, npm link replaces linked package contents #2380
Comments
Yikes, thats scary. |
@hdodov in what way would nvm prevent |
@hdodov can you install the latest |
@darcyclarke I can't reach the point of being able to reproduce. With a fresh install of Node
...which creates the symlink ( ...and indeed if I try to run
Here's the log: 2021-02-04T07_50_48_106Z-debug.log. I tried to link and unlink several times, but nothing seems to fix it. I guess that's for another issue, though? Let me know if I should open a new one. Maybe there's some issue with nvm for Windows? Although I had no issues with it specifically. |
@hdodov good to hear the initial issue seems to be resolved. I have heard of other folks using |
@darcyclarke actually, I don't know if it's resolved. That was my point in my previous comment - I couldn't get past the I'll experiment with other version management tools and post the update here. 👍 |
I installed Volta 1.0.1 and I didn't have the problems mentioned in my previous comment. I tried to reproduce the issue and it seems that it's half solved. Here's what I tested:
Basically, whenever I run a command that installs or uninstalls a package, the linked package is switched with the downloaded version if it's listed in package.json, or the link is simply removed if it isn't listed. What's different this time is that my child package (the one I'm linking) didn't get erased at any point during the testing, which is wonderful. The only real issue now is that I have to run OS: Microsoft Windows 10 Pro, 10.0.18363 Build 18363 |
To prevent npm install from overriding `npm link` outcomes or getting errors when running `npm ls` we must be sure we do always add `--save` Related: npm/cli#2380
To prevent npm install from overriding `npm link` outcomes or getting errors when running `npm ls` we must be sure we do always add `--save` Related: npm/cli#2380 Related: ansible/ansible-language-server#130
To prevent npm install from overriding `npm link` outcomes or getting errors when running `npm ls` we must be sure we do always add `--save` Related: npm/cli#2380 Related: ansible/ansible-language-server#130
|
As |
That behaviour doesn't make any sense for the intended usecase, though, and this is not how it worked in old npm versions (before So neither "overriding package.json with the substitute" nor "have the substitute be deleted every time you add a completely unrelated dependency" make sense here. The correct behaviour would be to retain the substitute across npm commands, without changing the Edit: This was supposed to be fixed in v7, by the way. |
The first part of the originally reported issue is still happening for me, with npm version 8.12.1.
Apparently this is now the intended behavior, but it wasn't always like this. I used to have a workflow using It was working well for a number of projects and linked modules, but at some point (I seem to recall it started in npm version 5.x) the behavior changed, where (This was never solved, and after a while I had to switch to With the current behavior, every time I run If this is the intended default behavior, would it be possible to add a CLI option to preserve linked modules as before? |
I find it odd the one of the most important development workflows hasn't been fixed for almost 2 years now. |
@vzakharov-rxnt While this bug is marked like linking would be broken only on Windows, the reality is that |
@ssbarnea We had issues with unit tests when dependencies were installed with yarn. Had to switch back to npm. |
After many years using |
@Vasile-Peste - The link package along with a
{
"scripts": {
"prepare": "(test -f link.config.json && npx link) || true"
...
}
} |
Both packages should exist as symlinks. |
Still getting this with npm version |
I've been having issues with my dev workflow and this lately. While it seems counter-intuitive to blow away a linked local package, I've decided that the answer is to have an To help me around this I'm going to write a script/tool in the coming day or so that goes through and looked at linked global packages (either symlink or junction), and calls link on each of either the specified one, or all of them. |
I have specified a package in my package.json that I have also linked with a local version I use for development. When I run
npm i
in the parent package, the symlink is removed, the package is installed from npm, and I use the live version instead, not my local development one.Later, if I run
npm link
, the package correctly get linked with my local version, but everything is replaced with the downloaded version, meaning that all my local development files are replaced with the contents of the tarball downloaded from npm. This means I have to go in my package folder, clone the repo again, checkout the files from the master branch... Not to mention that if I have any unsaved work, it would get completely erased with no chance to get it back even via Git - because the.git
folder is also deleted.Current Behavior:
npm i
removes linked packages and installs their published versions insteadnpm link <package>
replaces the contents of the symlinked package folder with the published package's tarball contentsExpected Behavior:
npm i
should ignore packages innode_modules
that are symlinkednpm link <package>
should only create a symlink and leave everything in the symlinked folder intactSteps To Reproduce:
npm link
in a different, local version of the packagenpm link <package>
in the projectnpm i
npm link <package>
in the projectEnvironment:
The text was updated successfully, but these errors were encountered: