Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Yarn to reinstall a package?

My project has a dependency that I sometimes get from a package server and sometimes get from a local copy I have on my machine. As a result, I frequently need to have Yarn switch where it looks for the dependency. Furthermore, I often change the local copy of the dependency and need to see that change reflected in my main project. As a result, I need a way to tell Yarn to continue looking at the same location for the dependency, but to reinstall the dependency, skipping the cache and grabbing it directly from its current source, even when the version number hasn't changed. (Sometimes I want try small changes to the dependency, and updating the version number every time would quickly become annoying.)

How do I do so?

I've tried the following, but none of them work:

yarn remove dependency yarn add file:/dependency 

Continues to use the previous version of the dependency.

yarn remove dependency yarn cache clear yarn add file:/dependency yarn install --force 

Also continues to use the previous version of the dependency.

yarn remove dependency rm -rf node_modules/ yarn cache clear yarn add file:/dependency yarn install --force 

Still continues to use the previous version of the dependency.

How can I ensure that Yarn is using the latest version of my dependency?

like image 868
Kevin Avatar asked Jan 26 '17 00:01

Kevin


People also ask

What is yarn install force?

yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the project has added a new dependency that you need to pick up.

How do you refresh yarn?

In case one you should install reload globally with npm install reload -g . Also with reload installed globally you can go to any directory with an HTML file and use the command reload to constantly watch it and reload it while you make changes.


1 Answers

Reinstalling a package after just deleting the node module works with:

yarn install --check-files

like image 127
Karl Adler Avatar answered Sep 30 '22 08:09

Karl Adler