Skip to content
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 link removes other links #3745

Closed
1 task done
Gopikrishna19 opened this issue Sep 13, 2021 · 13 comments
Closed
1 task done

[BUG] npm link removes other links #3745

Gopikrishna19 opened this issue Sep 13, 2021 · 13 comments
Assignees
Labels
Bug thing that needs fixing platform:windows is Windows-specific Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@Gopikrishna19
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Linking package1

$ npm link @myscope/package1 

changed 1 package, and audited 603 packages in 10s
found 0 vulnerabilities
$ ll node_modules/@myscope
total 0
lrwxrwxrwx 1 Gopi 123 32 Sep 13 10:35 package1 -> /d/Projects/Websites/package1/
drwxr-xr-x 1 Gopi 123 0 Sep 10 12:09 package2/
drwxr-xr-x 1 Gopi 123 0 Sep 13 10:35 package3/

Linking package2

$ npm link @myscope/package2

changed 2 packages, and audited 603 packages in 10s
found 0 vulnerabilities
$ ll node_modules/@myscope
total 0
drwxr-xr-x 1 Gopi 123 32 Sep 13 10:35 package1/
lrwxrwxrwx 1 Gopi 123 0 Sep 10 12:09 package2 -> /d/Projects/Websites/package2/
drwxr-xr-x 1 Gopi 123 0 Sep 13 10:35 package3/

Expected Behavior

Linking package1

$ npm link @myscope/package1 

changed 1 package, and audited 603 packages in 10s
found 0 vulnerabilities
$ ll node_modules/@myscope
total 0
lrwxrwxrwx 1 Gopi 123 32 Sep 13 10:35 package1 -> /d/Projects/Websites/package1/
drwxr-xr-x 1 Gopi 123 0 Sep 10 12:09 package2/
drwxr-xr-x 1 Gopi 123 0 Sep 13 10:35 package3/

Linking package2

$ npm link @myscope/package2

changed 1 package, and audited 603 packages in 10s
found 0 vulnerabilities
$ ll node_modules/@myscope
total 0
drwxr-xr-x 1 Gopi 123 32 Sep 13 10:35 package1 -> /d/Projects/Websites/package1/
lrwxrwxrwx 1 Gopi 123 0 Sep 10 12:09 package2 -> /d/Projects/Websites/package2/
drwxr-xr-x 1 Gopi 123 0 Sep 13 10:35 package3/

Steps To Reproduce

  1. Start a project with multiple sibling dependencies
  2. Link a sibling package
  3. LInk another sibling package
  4. The first sibling is no longer linked

Environment

  • OS: Windows 10
  • Node: v16.3.0
  • npm: 7.15.1
@Gopikrishna19 Gopikrishna19 added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 13, 2021
@Gopikrishna19
Copy link
Author

Gopikrishna19 commented Sep 13, 2021

This works:

$ npm link @myscope/package1 @myscope/package2
$ ll node_modules/@myscope
total 0
lrwxrwxrwx 1 Gopi 123 32 Sep 13 10:35 package1 -> /d/Projects/Websites/package1/
lrwxrwxrwx 1 Gopi 123 0 Sep 10 12:09 package2 -> /d/Projects/Websites/package2/
drwxr-xr-x 1 Gopi 123 0 Sep 13 10:35 package3/

Is the new behaviour intentional? I surely remember multiple links working in previous versions of npm. Although I have only attempted it on a posix env.

@Gopikrishna19
Copy link
Author

Upgraded node to v16.9.1 with npm v7.21.1 and still not working. I see there was a fix 40829ec made which is available from 7.18. But it is not working on Windows.

Tagging #3399 #2554

@trusktr
Copy link

trusktr commented Sep 27, 2021

This has been an issue for forever. I've reported this before (but probably those are lost in archived repos or forums).

@barisusakli
Copy link

Just ran into this as well after upgrading to npm 7.x. I used to run a script to link 10+ dependencies like

npm link <dep1>
npm link <dep2>
npm link <dep3>
npm link <dep4>

@Gopikrishna19 thanks for the suggestion npm link <dep1> <dep2> ... <depn> works.

@wraithgar
Copy link
Member

40829ec should have fixed this. What does the error state look like now in windows?

@Gopikrishna19
Copy link
Author

Gopikrishna19 commented Mar 17, 2022

will test it now @wraithgar

@Gopikrishna19
Copy link
Author

Its still not working in Windows:

D:\Projects\test> md app1 ; cd app1 ; npm init -y ; npm link ; cd ..
D:\Projects\test> md app2 ; cd app2 ; npm init -y ; npm link ; cd ..
D:\Projects> md app3 ; cd app3 ; npm init -y

D:\Projects\app3> npm link app1 
D:\Projects\app3> npm link app2

D:\Projects\app3> ls node_modules
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----l         3/17/2022   3:20 PM                app2
-a----         3/17/2022   3:20 PM            366 .package-lock.json

Again, as mentioned a combined link works.

D:\Projects\app3> npm link app1 app2
D:\Projects\app3> ls node_modules
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----l         3/17/2022   3:18 PM                app1
d----l         3/17/2022   3:18 PM                app2
-a----         3/17/2022   3:18 PM            387 .package-lock.json

However, something did change. If I link both deps and link one again, it is not unlinking others anymore:

D:\Projects\app3> npm link app1 app2
D:\Projects\app3> npm link app2
D:\Projects\app3> ls node_modules
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----l         3/17/2022   3:18 PM                app1              # Still available
d----l         3/17/2022   3:18 PM                app2
-a----         3/17/2022   3:18 PM            387 .package-lock.json

@wraithgar wraithgar added Priority 1 high priority issue platform:windows is Windows-specific and removed Needs Triage needs review for next steps labels Mar 17, 2022
@Gopikrishna19
Copy link
Author

Gopikrishna19 commented Mar 17, 2022

Works in mac though:

~/Developer/npm-test                                                                                                                                                                  
❯ mkdir app1 && cd app1 && npm init -y && npm link && cd ..                                                                                                                                       
❯ mkdir app2 && cd app2 && npm init -y && npm link && cd ..                                                                                                                                                            
❯ mkdir app3 && cd app3 && npm init -y                   

~/Developer/npm-test/app3                                                                                                                                                 
❯ npm link app1                                                                                                                                                          
❯ npm link app2

~/Developer/npm-test/app3                                                                                                                                                     
❯ ll node_modules 
total 8
drwxr-xr-x  5 Gopi  123  160 Mar 17 15:26 .
drwxr-xr-x  4 Gopi  123  128 Mar 17 15:26 ..
-rw-r--r--  1 Gopi  123  403 Mar 17 15:26 .package-lock.json
lrwxr-xr-x  1 Gopi  123   10 Mar 17 15:26 app1 -> ../../app1
lrwxr-xr-x  1 Gopi  123   10 Mar 17 15:26 app2 -> ../../app2

@Gopikrishna19
Copy link
Author

Versions:

~/Developer/npm-test/app3
❯ npm --version
8.5.5
❯ node --version
v16.14.1
D:\Projects\app3> npm --version
8.5.4
D:\Projects\app3> node --version
v16.14.1

I guess I missed the v8.5.5, released 2 hours ago, on Windows. Your comment about the fix was from yesterday, so I guess v8.5.4 is still valid. Please let me know if you want me to test with 8.5.5 on Windows.

@wraithgar
Copy link
Member

No, there were no changes in 8.5.5 that would be relevant to this bug.

@Santoshraj2 Santoshraj2 self-assigned this Dec 20, 2023
@Santoshraj2
Copy link
Contributor

@Gopikrishna19 can you please retest this in windows and confirm if issue is till there.
I tried in windows machine and its seems to be having both the links when tried linking individually, Please recheck and confirm.

@wuleninja
Copy link

Hi ! Having this issue right now (WSL2 / Ubuntu). Figured that I had to npm link moduleA moduleB to have them since, since linking moduleA unlinks moduleB. Or is it the expected behaviour?

@Mortimer333
Copy link

Hi ! Having this issue right now (WSL2 / Ubuntu). Figured that I had to npm link moduleA moduleB to have them since, since linking moduleA unlinks moduleB. Or is it the expected behaviour?

bump, encountered same issue Ubuntu 22, node v20.12.1, npm 10.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing platform:windows is Windows-specific Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

7 participants