Reputation: 4727
I'm learning about using yarn link
to work on a package and have changes reflected in a host app and I either don't get something or somethings not working.
It is all built in angular5..
I have an app MyApp that contains, among others, @org/my-package
in node_modules
.
I need to make changes to my-package and in order to serve the changes I use yarn link
to create symlink and test the package in MyApp.
This is what I do...
In my-package, I run a build. It creates the distribution files. I then cli into dist package and run yarn link
.. This is success.. I get the instruction to use yarn link @org/my-package
in MyApp cli..
Then I go to MyApp, and I run yarn link @org/my-package
. This is success as well..
However when I make changes in my-package and run a build again, they don't get reflected in MyApp.
What am I not understanding?
I get no errors.
Is @org/my-package
that is in node_modules
in MyApp supposed to be there or not? Isn't yarn link
on the dist in my-package meant to override that one?
No matter how much I search it looks like yarn documentation is a bit light on this topic.
Upvotes: 12
Views: 18867
Reputation: 31
I had this problem too.
When I updated my library, it didn't reflect in my main project. I looked inside the modules and there was my package. Everything was fine and up to date, nothing was wrong. That's when I decided to delete the angular\cache
folder, and it worked. Try this setting inside your angular.json. It worked for me:
"cli": {
"cache": {
"enabled": false
}
}
For more information on clearing cache
Upvotes: 1
Reputation: 31
Delete node_modules and reinstall all the packages and reset yarn link your_local_package
work fine for me.
Upvotes: 3
Reputation: 59
I faced similar kind of a issue. But what I did was edit the package.json in the project that depends on the component library to for example "@org/my-package": "link:../packages/dist/my-package" (edit the path) This only works with yarn, if you use npm this is not an option, but you could use npm link.
I had to do a yarn install after that in the project. So, when you re-build my-package, the @org/my-package that is in node_modules in MyApp supposed to be updated.
Upvotes: 5