Home > Mobile >  create a npm cache shared proxy for an organization
create a npm cache shared proxy for an organization

Time:01-07

I'd like to know if there is a tool that can be deployed on an organization network to cache packages and speedup build time ?

It should work transparently for the end user

  1. Connected to the organization network, user A download a package through the proxy cache
  2. The proxy cache check if it has locally. If yes it send back to user, otherwise it downloads it, save it before sending
  3. If disk allocated is full, it just downloads from npmjs before sending
  4. If a userB connected to the same network ask for same package, it doesn't download again from npmjs and send it directly

CodePudding user response:

To create a npm cache shared proxy for an organization, follow these steps:

Set up a server that will host the npm cache. This could be a dedicated physical server or a virtual machine in the cloud.

Install Node.js and npm on the server.

Create a new npm registry using the npm-registry-couchapp package. This will create a CouchDB database that will store the packages in the npm cache.

Configure the npm client on each developer's machine to use the npm cache as a proxy. This can be done by setting the proxy and https-proxy properties in the .npmrc file located in the user's home directory.

To publish packages to the shared cache, developers can use the npm publish --registry command, specifying the URL of the npm registry as the value for the --registry flag.

To install packages from the shared cache, developers can use the npm install --registry command, again specifying the URL of the npm registry as the value for the --registry flag.

By using a shared npm cache, developers in an organization can avoid having to download the same packages multiple times, saving time and bandwidth. It also allows for more control over the packages that are used in an organization's projects, as only packages that have been published to the shared cache can be installed.

CodePudding user response:

Just asked chatgpt and discover verdaccio: https://verdaccio.org

  • Related