question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docs: caching node_modules vs cache directory

See original GitHub issue

The docs guides to cache .npm or $(yarn cache dir) for nodejs.

Node - npm Node - Yarn

This lets people feel it the “RIGHT” way to cache node dependencies, without clearly explaining whether caching node_modules directly is not recommended.

I want to know 1) if this is a wrong impression or not and 2) why.

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

6reactions
Arxciscommented, Aug 10, 2021

Yes. I would like to know the answer here as well. From experience caching node_modules/ saves a lot more time, than just caching $(yarn cache dir) 🤔

In my github workflow here are my results from different caching strategies vs no-caching:

yarn install - no-caching yarn install - cache hit $(yarn cache dir) yarn install - cache hit node_modules/
1m 50s 1m 1-2s

Up to 60x faster when caching node_modules/ directly vs caching $(yarn cache dir) 🤔

0reactions
vsvipulcommented, Aug 29, 2022

This has already been added to Node example at https://github.com/actions/cache/blob/main/examples.md#node---npm . Hence, going ahead and closing this. Thank you for opening this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-cache
This directory is a cacache -based content-addressable cache that stores all http request data as well as other package-related data. This directory is ......
Read more >
Caching dependencies to speed up workflows - GitHub Docs
To make your workflows faster and more efficient, you can create and use caches for dependencies and other commonly reused files.
Read more >
Caching in GitLab CI/CD
By default, npm stores cache data in the home folder ( ~/.npm ). ... PHP libraries modules are installed in vendor/ and are...
Read more >
Caching Dependencies - CircleCI
A cache stores a hierarchy of files under a key. Use the cache to store data that makes your job faster, but, in...
Read more >
Caching Dependencies and Directories - Travis CI Docs
Caches lets Travis CI store directories between builds, which is useful for ... This caches $HOME/.npm or node_modules , depending on the repository's ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found