Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
130
rated 0 times [  135] [ 5]  / answers: 1 / hits: 25931  / 7 Years ago, sun, april 30, 2017, 12:00:00

I assume when I install npm package say react for the first time with


yarn add react

this will save react file in local cache. I found .yarn-cache to contain many files. I assume it is yarn local cache folder so that when I install react again in the future, it will be installed from local cache, no??


If I need to install react again in the future, should I simply write this:


yarn add react

or this:


yarn add react --prefer-offline

More From » node.js

 Answers
8

My understanding is that by default, yarn will always try to download the package from the internet when you install/restore it, and will also store that in the cache, which means that in the future if you try to install/restore and don't have an internet connection, it can fall back on the cache and install from there if necessary. By specifying --prefer-offline, you are reversing this behaviour so that it will check the cache first, and only try to download the package from the internet if it cannot find it in the cache. This can make your install/restores significantly quicker, and will allow you perform repeatable builds, but you may not get the latest versions available (e.g. if you're using version specs like ~1.2.3). There is also an --offline option, which will throw an error if it can't find a package in your local cache (i.e. it won't ever try to download from the internet).



More info at https://yarnpkg.com/blog/2016/11/24/offline-mirror/


[#57956] Thursday, April 27, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destiniemartinac

Total Points: 92
Total Questions: 106
Total Answers: 111

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;