jdx / npm-register

Your own private npm registry and backup server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm-register doesn't proxy from npm

bitsandbytes opened this issue · comments

After an initial installation where npm-register was proxying just fine, I re-installed and now am unable to get any success.

Before I go any further: I'm running on CentOS 7.3.1611, npm 5.5.1, npm-register 2.5.2. The installation is tricky only because bcrypt/node-gyp aren't building the bcrypt library unless I make the build dir and then run:

npm install -g --unsafe-perm npm-register

The logs below show npm-register receiving the GET and return 404. The local filesystem, /opt/npm-register, is empty, it hasn't created the packges or tarballs dirs.

What obvious thing am I doing wrong here?

Opbeat agent is inactive due to configuration
Saving files to local filesystem at /opt/npm-register
app listening on port 3000 [development]
measure#request=52ms method=GET user-agent="npm/3.10.10 node/v6.12.0 linux x64" status=404 path=/node-fetch request_id=0.668435448069421
Writing /opt/npm-register/auth_tokens
measure#request=18ms method=PUT user-agent="make-fetch-happen/2.5.0 (+https://npm.im/make-fetch-happen)" status=201 path=/-/user/org.couchdb.user:admin request_id=0.4348165676233098
measure#request=3ms method=GET user-agent="npm/5.5.1 node/v8.9.2 linux x64" status=200 path=/-/whoami request_id=0.09457657591989399
measure#request=26ms method=GET user-agent="npm/5.5.1 node/v8.9.2 linux x64" status=404 path=/node-fetch request_id=0.8804010594290754

We ran into the same problem and after some debugging I think the problem is at https://github.com/jdxcode/npm-register/blob/master/lib/npm.js#L54. req.body is a string, not an object. I wrapped it in JSON.parse and it works as expected.

Maybe someone who is familiar with the codebase knows why this change is needed?

Thanks for putting your monkey patch here. I tried out verdaccio which sort of "just worked" so I'm going with that. But hopefully the peeps here will make note of your fix. This is a cool project.

The above solution worked for me too.