EC2 Ubuntu 实例 npm 未安装任何包

EC2 Ubuntu instance npm is not installing any package

我在安装任何包时都出错,即使我 运行 sudo npm i -g npm 我也遇到同样的错误:

npm ERR! Linux 4.15.0-1032-aws
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "-g" "npm"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect

npm ERR! network connect ETIMEDOUT 104.16.16.35:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

我不知道从哪里开始调试,我以为我的互联网有问题但我可以从我的 EC2 实例 ping google.com,即使我 ping 104.16.16.35 我得到响应数据包。

EC2实例出站规则:

curl -I 104.16.27.35:443

的卷曲响应
curl: (7) Failed to connect to 104.16.27.35 port 443: Connection timed out

npm 下载将通过 https 安装的软件包,因此您应该将端口 443 添加到安全组配置的出站规则中。