I am trying to create my own verion of local-npm
I have this simple http server:
#!/usr/bin/env node
'use strict';
import http = require('http');
const s = http.createServer(function (clientRequest, clientResponse) {
if (clientRequest.url === 'x') {
clientResponse.write('retrieve the tarball from local fs');
clientResponse.end();
return;
}
const proxy = http.request({
hostname: 'https://registry.npmjs.org',
port: 80,
path: clientRequest.url,
method: clientRequest.method
},
function (res) {
res.pipe(clientResponse);
});
clientRequest.pipe(proxy);
});
s.listen(3441);
In a local terminal, I run:
npm config set registry "localhost:3441"
and just for kicks I run this too:
npm set registry "localhost:3441"
and to confirm it worked, I do:
$(npm get registry) => "localhost:3441"
but then when I run npm install
, nothing gets intercepted by the proxy, everything just goes to NPM.
What am I doing wrong?