Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing package is node_modules has no effect in create-react-app project

I am trying to work on a package locally that is a dependency in a react project. I want to debug an issue while it's running in the main react project.

simply using yarn link creates duplicate versions of react that breaks hooks. (I also tried yarn linking react and react-dom and it get's harry and I was seeing other issues with that)

So I thought to myself, I have an idea. I can just do this:

rm ./node_modules/<my-package>/dist
ln -s /<path-to-my-dev-package>/dist ./node_modules/<my-package>/dist

And that would be the equivalent. I just need to run yarn build on my package before testing it in my app.

The problem is, I cannot get yarn to "see" the changes.

I have verified the symlink is there. I have verified the changes in the built files.

yet no matter what I do, the old non symlink'd version is what I see.

I tried:

yarn cache clean
yarn start

But it still see the old/deleted version of my pacakge (that no longer even exists) when I run my project

How can I get it to "refresh" to the new symlink'd build files?

TLDR

Even if I don't use symlinks.. any change I make to a package in node_modules is not reflected when I run the app.

So real question is, how are these node_modules being cached in create-react-app and how can I clear it so that my changes in node_modules are seen, so I can debug them.

like image 442
JD Isaacks Avatar asked Jul 17 '26 05:07

JD Isaacks


1 Answers

After poking around in the source of react-scripts

It seems I need to remove ./node_modules/.cache/default-development to clear it and reload the changes.

like image 100
JD Isaacks Avatar answered Jul 19 '26 21:07

JD Isaacks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!