I had the same issue. The reason was the corporate proxy issue. Solution was to set the proxy setting as @rsp says.
npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080
But later I face the same issue. This time reason was my password contains a special character.
In this command you can’t provide a password with special character
. So solution is to provide percentage encoded special character in the password.
For example # has to provide as %23