The tip in this section is confusing because it seems like it's suggesting not to do what the example is doing.
Could the example be updated to reflect a more proper usage of caching npm packages?
Or, if it makes more sense to use npm ci over caching npm packages in most situations could the tip be updated to reflect that?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@nlaveck -- thank you for your question. It looks like you're working through an issue with your scenario or implementation. Here are a couple of options where you might consider asking your question:
cc @ramiMSFT for awareness
@WilliamAntonRohm I'm not asking for support. My questions are purely for the purpose to suggest improvements to the documentation. Unless if I'm misunderstanding the documentation, the tip in the section is saying to avoid doing what the example is doing.
What's the purpose of the example if immediately after it the documentation suggests not to do it that way?
Could you please reopen this and retag it since this isn't a support request?
@nlaveck -- thank you for clarifying.
@ramiMSFT -- please look into this issue.
@nlaveck
I assume you are talking about the following:
Because npm ci deletes the node_modules folder to ensure that a consistent, repeatable set of modules is used, you should avoid caching node_modules when calling npm ci.
The example caches the "shared cache directory." not the node modules. So its not contradicting. though I thought the exact same thing as well. :)
@nlaveck Thank you for your feedback. There is no contradiction between the example and the Tip in the documentation.
The docs states that: "The recommended way is to cache npm's shared cache directory". This directory contains a cached version of all downloaded modules.
The example follows that recommendation and caches the shared cache directory (Not the node_modules).
The Tip is advising against caching the node_modules because running the npm ci script will delete the node_modules folder.
I hope this clarifies any confusion.
@Patrickkk Thank you for your contribution!
Thanks @Patrickkk and @ramiMSFT! I misread that section and thought both the tip and example were referring to the node_modules directory. Using the shared cache directory makes sense.
Most helpful comment
@nlaveck
I assume you are talking about the following:
Because npm ci deletes the node_modules folder to ensure that a consistent, repeatable set of modules is used, you should avoid caching node_modules when calling npm ci.
The example caches the "shared cache directory." not the node modules. So its not contradicting. though I thought the exact same thing as well. :)