0

I'm hosting a npm registry on a TFS 2017 server, with the Package Management extension. Its hostname has a single part, dnsXxx, without any extension like .com, and is configured on the port 8080. I'm using a .npmrc file to define this repository for packages in the scope @abc:

@abc:registry=http://dnsXxx:8080/tfs/.../npm/registry/
@abc:proxy=null
@abc:always-auth=true

When I tried to install one of its packages, using a command like npm i @abc/mypackage, from the folder containing the .npmrc file, the command is taking a long time to finally fail with npm ERR! 503 Service Unavailable: @abc/mypackage@....

Using WireShark, I figured out that the url called by npm has been modified, I guess "normalized" that way: GET http://www.dnsXxx.com/tfs/.../npm/registry/@abc%2fmypackage HTTP/1.1, resulting in:

  • Port is missing
  • www. host prefix and .com host extension have been added improperly

If I call the fixed url in a browser, http://dnsXxx:8080/tfs/.../npm/registry/@abc%2fmypackage, I get the expected JSON answer.

Does anyone see a solution?

Community
  • 1
  • 1
Romain Deneau
  • 2,841
  • 12
  • 24

1 Answers1

1

The issue was due to the entreprise proxy, called even with proxy=null in the .npmrc file. It's the proxy that is reformating the hostname. When I switched to the server IP address, updating the auth token, it has finally succeeded:

@abc:registry=http://10.x.y.z:8080/tfs/.../npm/registry/
@abc:always-auth=true

; Treat this auth token like a password. Do not share it with anyone, including Microsoft support. This token expires on or before 05-Feb-18.
; begin auth token
//10.x.y.z:8080/tfs/.../npm/registry/:_authToken=...    
//10.x.y.z:8080/tfs/.../npm/:_authToken=...  
; end auth token

Other option: using a FQN for the server name (xxx.yyy.zzz instead of just xxx) which won't be changed by the proxy (into www.xxx.com).

Romain Deneau
  • 2,841
  • 12
  • 24
  • I have the same issue of `ERR! 503 Service Unavailable` on some dependencies of my project even though I correctly set `registry=http://srvnexus/nexus/repository/npm-all/` in the project `.npmrc` file .. Do you have some suggestions plz ? – Ghassen Aug 16 '18 at 09:11
  • 1
    @ghassen: the issue is due to the "short dns" name, `srvnexus`. Use a long name instead (if possible in your network), `srvnexus.local` for instance. Else, try with IP address. – Romain Deneau Aug 16 '18 at 14:02
  • Coool ! It works really with the IP address of nexus ;) Thank you so much – Ghassen Aug 16 '18 at 14:21
  • @ghassen: what about marking the question/answer as useful with a "+1" ? ;) – Romain Deneau Aug 17 '18 at 08:36
  • 1
    I have done it for the comment .. I thought it would be the same .. but now I did it for the response ;) Bonne journée – Ghassen Aug 17 '18 at 08:47