Skip to content

fix(link): output symlink created by npm link - #10203

Open
ShryukGrandhi wants to merge 1 commit into
npm:latestfrom
ShryukGrandhi:fix/issue-3177-bug-npm-link-does-not-inform-about-symli
Open

ShryukGrandhi wants to merge 1 commit into
npm:latestfrom
ShryukGrandhi:fix/issue-3177-bug-npm-link-does-not-inform-about-symli

Conversation

@ShryukGrandhi

Copy link
Copy Markdown

Summary

Since npm 7, running npm link in a package directory no longer tells you where the global symlink went. npm 6 printed a line like /path/to/global/node_modules/pkg -> /path/to/project. This adds that line back.

Fixes #3177

Changes

  • lib/commands/link.js: after the global reify in linkPkg, print <link path> -> <target> for each explicitly requested package (the current package, or each selected workspace). The line is skipped with --json, because the JSON summary already includes the path and the extra line would make the output invalid JSON.
  • test/lib/commands/link.js: assert that the link line is printed for npm link with no args, and that nothing extra is printed with --json.

Example:

$ npm link
/usr/local/lib/node_modules/@my-package/cli -> /path/to/project

added 1 package in 1s

Testing

  • node . run test -- test/lib/commands/link.js passes, with 100% coverage for lib/commands/link.js. The new assertion fails without the change to link.js.
  • npx eslint lib/commands/link.js test/lib/commands/link.js is clean.
  • Ran it by hand with a temporary global prefix (npm_config_prefix=<tmp> node . link) on a package with a bin field. The link line was printed, and the --json output still parses as JSON.

Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
@ShryukGrandhi
ShryukGrandhi requested a review from a team as a code owner November 2, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm link does not inform about symlinked packages to global node_modules anymore

1 participant