An example of how to set up a npm project-specific cache/mirror of deps (similar to yarn's offline mode). You can read more about npm-cache @ docs.npmjs.com/cli/cache.
- Create an
.npmrc
file in your project's root with the following
# choose a directory were you want to cache your deps
cache = ./npm_cache_mirror
- Run
npm install
- Your
./npm_cache_mirror
directory will now have a cached version of all your deps
- If you want to check in this cache (which is somewhat expected) ensure you also check in your
package-lock.json
ornpm-shrinkwrap.json
files to ensure everything gets properly resolved - You'll probably want to
.gitignore
your cache's log files but keep the folder to avoid any warnings/errors (ie.npm_cache_mirror/_logs/*.log
&npm_cache_mirror/anonymous-cli-metrics.json
)
You can test out this method of caching/mirroring deps by: