-
Notifications
You must be signed in to change notification settings - Fork 195
Add an option to skip caching node_modules #165
Conversation
Some packages do not expect the node_modules directory to be cached and have trouble installing themselves a second time. If the $CACHE_NODE_MODULES environmental variable is false the build will skip caching or attempting to use a cached node_modules directory. If $CACHE_NODE_MODULES is unset or true then node_modules will continue to be cached.
@jrjohnson Do you have more information on what data those modules are storing outside of |
@brycekahle I'm honestly not that certain. It seems to be standard when there is a native compilation step. My builds usually fail with a can't find Bad practice or not this regularly forces us to Retry Deploy with the clear cache option. Which means we also loose the excellent yarn cache and have to fetch all packages from the network. |
I believe many packages save the built assets in directories in |
I'm not rejecting your proposed solution. I'm trying to understand the problem better before taking any action. Do you have an example of the error you see when running a build with a cache? |
I understand. I'm happy to answer as many questions as you have and try something else. I just figured a PR would be easier to discuss than a more abstract issue. I have always felt that The specific message we get when a build fails is: https://app.netlify.com/sites/ilios-frontend/deploys/5aaff42192226a1217716b63 Detailed build log:
|
(Sorry for another drive by!) From the log above, it seems that that Netlify site/project is using a very old version of yarn (v0.18.1 vs the netlify build script default of v1.3.2), so this might be a case of just needing to update (or unset) your |
@edmorley we're not declaring a specific yarn version anywhere that I can find. I will investigate that some more to see if it is a solution to this issue. Thanks. Edit: Forcing yarn with |
@brycekahle just checking back in to see if you need more information. |
@jrjohnson Would you mind reaching out to support (and referencing this issue)? I'm pretty sure we have others who use |
Support was unable to diagnose my issue. But suggested I add |
Why?
Some packages do not expect the
node_modules
directory to be cached andhave trouble installing themselves a second time.
Most recently we have been unable to build a project that contains sharp which has a compilation step that stores data outside of the
node_modules
directory. We have to manually force a build wit a cleared cache each time. In the past we have had similar issues with node-sass.What changed?
If the
$CACHE_NODE_MODULES
environmental variable isfalse
the build will skipcaching or attempting to use a cached
node_modules
directory. If$CACHE_NODE_MODULES
is unset ortrue
thennode_modules
will continue tobe cached.