Yes, not using "sudo" won't fix your issue. My point was just that you should not be using "sudo" for this in any scenario.
The stack exchange post that I linked was quite old. Here is something newer: https://medium.com/@d_dhana/working-with-npm-behind-network-proxy-444ced82a3
Unfortunately, I can't really help you with this other than to point you to things I find on the internet. I don't have a proxy requiring authentication to work behind and test this.
You could try cloning the webwork2 and pg repositories on a computer that is not behind a proxy, then run "npm ci" there (you only need to have node and npm installed on that computer for this to work), and then copy all of the htdocs directories to your server.