An article on Medium by Alex Mills lays it out bare.
It says the difference between npm link x and npm install /local/path/to/x are:
-
The big difference is that
npm install /local/path/xwill
run the preinstall/postinstall hooks, butnpm link xwill not. -
npm linkuses the global NPM space,npm install /local/path/xdoes not. npm link creates a symlink to x
in the global space, and then when you call npm link x from
y, it creates a symlink not directly to x, but rather to
the global symlink. This is an important differences if you are
using different global node.js versions, e.g., NVM. -
npm install /absolute/path/xwill alter package.json,npm link x
does not.
To get a fresh local copy instead of a symlink, use npm pack, like so:
tgz="$PWD/$(npm pack)"
cd <other project>
npm install "$tgz"
You could also use cp/rsync, but that wouldn’t run install hooks or put the executables in node_modules/.bin…that will work.