0

I use custom built library and then link them between other libraries using 'npm link'. One problem is that,

if I do 'npm install' the links disappear and then I will have to go manually and do the linking.

In order to solve this issue, I am thinking of building a script to do npm link across libraries wherever needed but I am not sure if that will work because we will have to do npm link on the exact path from command line instead of running from a common path from command line.

Example:

I have built a library called, @mycustomlib/ui-components and I use them in other projects.

In order for me to use it, I would have to do the link in the appropriate project folder else I wouldnt be able to import.

shilovk
  • 11,718
  • 17
  • 75
  • 74
Johnson Samuel
  • 2,046
  • 2
  • 18
  • 29

1 Answers1

1

Any npm link you've set up will be overwritten when you npm install.

One option to avoid having to relink every time you npm install might be to create a new script in package.json like this:

"scripts": {
  "install-local": "npm install && npm link @mycustomlib/ui-components"
}

Then just run npm run install-local.

zkuzmic
  • 64
  • 4