I have a local node module foo
I'm working on, as a git submodule in my project. It's at $TOP/submodules/foo
. I understand I can do:
(cd submodules/foo && yarn link)
yarn link foo
and that will create a chain of two symlinks from node_modules/foo
to submodules/foo
and now I can use it just like any other npm module in my main project, and it immediately reflects changes I make. Cool. But how is that any better than just:
ln -s ../submodules/foo node_modules/foo
? It doesn't seem that yarn records the symlink anywhere, so it won't sync to my other dev machines or anything.
Is there some good reason I should be using yarn link
?
I believe yarn internally does shimming for you, so that you can use it in multiple platforms where ln -s
is simply not recognized.
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/link.js#L34 https://github.com/yarnpkg/yarn/blob/master/src/util/fs.js#L679
Also, it handles other subtle things for you and the syntax is simpler.