I am looking to create a locally running Node.js server that can intercept outgoing requests to the NPM registry (npmjs.org, or whatever).
Is that what a reverse proxy is?
Basically what I would like to do is create a locally running NPM registry - this is for use with locally running Docker containers. Normally I would just use npm link
for local development. But when testing libraries using Docker locally, using npm link
for that becomes hard to impossible
I know there are some libraries out there that set up a local NPM registry, but I am looking to do this from scratch so I can set it up for my use case. Essentially I want to tarball packages that exist on my filesystem each time an npm install
request comes in.
I started experimenting with:
npm config set registry http://localhost:3440
but when I subsequently did an npm install
, it didn't seem to hit my locally running server, just went to registry.npmjs.org
like normal.
I also tried modifying /etc/hosts
before:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
after:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
registry.npmjs.org localhost:3440
but my local server listening on port 3440 did not seem to intercept any traffic.