简体   繁体   中英

How to use one node_modules for all projects

Is there an easy way to share one node_modules folders with all angular projects and thus avoiding to download same dependencies every-time when we create a new project ? if yes , is the method recommended ( what are pros/cons)

Thanks for your time

Package Managers namely npm and yarn have caching mechanism. The packages are download for the first time only and when you run the install command for the already downloaded package, they won't be downloaded again.

That being said even if you don't have an internet connection you can still install previously cached packages.

Yarn is particularly awesome on handling this and npm is now catching up.

This solves your problem of downloading the packages again. Do lock your package dependencies version. This might help in using the same node_modules for other projects too. But I don't recommend using same node_modules folder for all projects personally as this might mess the entire project. Check out my article about dependency management in JS apps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM