Local npm registry clone to reduce package duplication

I'm just wondering if there is such a way that instead of loading fresh npm packages for each new node js project, we can load regularly used packages and dev dependencies to a local machine with different versions and then use node js in the project. In short, I would like to download npm packages from the npm registry once and save them locally on the file system, and for any new project that requires one or more of these packages, I can refer to the system path of the local file and do not need to download a fresh package from npm. The main goal is to keep redundancy as low as possible. All understanding would be greatly appreciated.

+4
source share
2 answers

You can configure npm to use a proxy server.

# For HTTP
npm config set proxy http://your-proxy-server:8080

# For HTTPS
npm config set https-proxy https://your-proxy-server:8443

You can use nginx, polish or squid as a reverse proxy cache. This will save a copy of the downloaded files, and you can configure how it is done and for how long. Note that npm itself also caches files.

+1
source

An interesting solution is: http://www.verdaccio.org/

It does what you need with a little configuration. It is well documented and maintained.

I installed it on a small machine inside our company's internal network, and my whole team added it to the npm registry.

0
source

Source: https://habr.com/ru/post/1677146/


All Articles