privatenumber / link

🔗 A better `npm link`
197 stars 8 forks source link

Add documentation explaining symlinks being removed after installing a new package #16

Closed ataylor32 closed 1 year ago

ataylor32 commented 1 year ago

Feature request

Currently, my link.config.json file has one symlink set up. Running npx link creates the symlink, as expected. However, if I run npm install <package>, the symlink gets deleted and I have to run npx link again to recreate it. I don't know if this is the intended behavior or not. If it's not intended then you can consider this issue a bug report. But if it is intended then I think it should be mentioned in the README.

Motivations

I don't think I'm the only one who will ever encounter this.

Alternatives

No response

Additional context

No response

Contributions

privatenumber commented 1 year ago

npx link and npm are completely unrelated tools.

npm install enforces the integrity of node_modules by making sure its contents are mapped to the right directories. Deleting existing files (e.g. symlinks) is a side effect of this.

Therefore, both tools are behaving expectedly.

In the perspective of npx link, npm install deleting the symlinks is just as arbitrary as some user manually deleting the symlinks. npx link is not involved or aware of that happening. And it's not a npx link bug that someone or something decides to delete the symlinks it creates.