在 Windows 10 下 npm install 失败,并报错:
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: connect ETIMEDOUT 104.20.22.46:443
gyp ERR! stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
gyp ERR! System Windows_NT 10.0.19640
.....
gyp ERR! node -v v12.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat@2.3.18 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.18 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
删除目录下的 node_modules 文件夹,再次 npm install
即可。
参见 github 上关于解决 node-gyp rebuild
的方案。
npm install --global --production windows-build-tools
from an elevated PowerShell or CMD.exe (run as Administrator).