npm / npm/cli

[BUG] npm link confused by symlinks (windows)

Open
#2,828 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug platform:windows Priority 2 Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Current Behavior:

I am creating a npm link to a package I am creating, and npm link creates a link to the wrong location.

Expected Behavior:

Create a link to the correct folder.

Steps To Reproduce:

Environment:

  • symlink directory: c:\code to c:\Users\WORMSS\code < because I am lazy and don't want to type the full path all the time
    • See (1) in image
  • config prefix c:\\program files\\nodejs
    • See (2) in image
  • package location: c:\Users\WORMSS\code\@wormss\genstack
    • See (3) in image
  • symlink directory c:\program files\node to c:\Users\WORMSS\AppData\Roaming\nvm\v15.9.0 < because that is where nvm installs the versions but NVM isn't required to setup the symlink
    • See (4) in image

image

Steps:

  • navigate to c:\code\@wormss\genstack (note, the shortcut of c:\code, not the full path through users)
    • See (3) in image
  • npm link < this makes genstack in global
    • See (5) in image
    • You will see it has made a link to c:\users\WORMSS\AppData\Roaming\code\@wormss\genstack instead of c:\code\@wormss\genstack
Environment:

OS: Windows 10
Node: 15.9.0
npm: 7.5.3

My thoughts (though I know nothing about what it is trying to do internally)
  • Possibly a root problem? Mistaking c:\code with \code o
  • Possibly a relative path problem? Mistakenly trying to do ..\..\ to get from c:\program files\nodejs to c:\ but mistakenly it taken it to c:\users\WORMSS\AppData\Roaming instead?
  • The only other coincidence I see, is that I do have a 'code' folder in c:\Users\WORMSS\AppData\Roaming\Code
    • But this has nothing at all to do with my code or nvm or npm or node.
    • I think this is to do with VSCode, but maybe npm is testing ..\..\code thinking it's testing c:\code but is actually hitting c:\Users\WORMSS\AppData\Roaming\Code and passing a test?? Maybe? no idea..

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Windows npm link entry point and reproduce the command using the symlinked paths and environment listed in the issue. Done means the global link resolves to c:\code\@wormss\genstack rather than the incorrect roaming path, with the Windows symlink scenario verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.