7

i'm struggling to use npm link. in fact i have two local packages that i would like to use in my project.

on each of the packages I performed the sudo npm link command. when I do an npm -g list I can therefore see these packages and their reference.

When I make an npm link <my-package-1> in my project, this add a symbolic link of my first package in node_modules. So far, so good.

Only when I make an npm link <my-package-2> in my project. npm first removes the symbolic link from my first package in node_modules and after he create a symbolic link to the second package in node_modules. I don't know why but I can't have more than one package with the link in my project.

Also when I do an ls of my node_modules folder, I see that the symbolic link is directed to my package folder and not to the node_modules folder of my global npm.

Am I missing something? I thought that was exactly what made an npm link different from an npm i ../path/to/my/package.

Thank you and good day

lhapaipai
  • 336
  • 2
  • 9
  • I upgraded Ubuntu from 9.10 to 20.04, Nodejs from 10.22.0 to 16.9.1 and NPM from 6.14.6 to 7.21.1. I have 8 modules that I have been linking for years and working on them on daily basis. After moving to the latest Ubuntu and nodej software stack, no longer being able to link. I have tried all suggestion in other post [link](https://stackoverflow.com/questions/24550515/npm-after-npm-link-module-is-not-found) with no success. NPM -g list shows packages are linked globally in /usr/lib but multiple links to package_name only creates sym_link to the last package on the list of ocmmands. – E.Z. Oct 03 '21 at 19:04

1 Answers1

12

Finally, I solved my issue with

npm link <my-package-1> <my-package-2>

But the symbolic link is directed to my package folder and not to the node_modules folder of my global npm.

lhapaipai
  • 336
  • 2
  • 9