This package re-establishes symlinks after npm i
has run. This shortcoming of npm is a known issue that the npm team has been slow to fix, so here is a package to do it.
% npm install -g npm-relink
Initialize from your project root:
% npm i -D npm-relink
% npm-relink init
% echo ".npm-relink.json" >> .gitignore
Add a postinstall
script to package.json
:
"scripts": {
"postinstall": "npm-relink"
}
Any time you run npm install
, npm-relink
should run afterward. If it doesn't, just run npm i
again.
When you add a new link using npm link
, run npm-relink init
afterward to capture changes.
I wish there were a way to do a post hook for dependency installation via npm install <package>
. Something like depinstall
ticket opened here