C:\Users\**>npm install --global --production windows-build-tools npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org/windows-build-tools failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org npm ERR! network This is a problem 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' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\**\AppData\Roaming\npm-cache\_logs\2021-05-23T14_32_42_600Z-debug.log
出現以上問題怎么解決?
1、執行: npm config get proxy npm config get https-proxy 如果返回值不為null,繼續執行: (這一步很重要,一定要保證兩個命令的返回值都為null,話說回來,應該出現這個錯誤這兩個返回值有不為null的)(這里博主兩個都不為null) npm config set proxy null npm config set https-proxy null 2、執行: npm config set registry http://registry.cnpmjs.org/
路徑地址:用npm安裝報錯 reason: getaddrinfo ENOTFOUND server server:80 (代理器設置問題)以及npm+指令沒有反應的問題_大芊與小箎的博客-CSDN博客
執行上述操作后,再次執行還是報錯:
C:\Users\**>npm install --global --production windows-build-tools npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID npm ERR! errno ERR_TLS_CERT_ALTNAME_INVALID npm ERR! request to https://registry.cnpmjs.org/windows-build-tools failed, reason: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\**\AppData\Roaming\npm-cache\_logs\2021-05-23T14_41_11_522Z-debug.log
查看npm config ls,如下:
C:\Users\**>npm config ls ; cli configs metrics-registry = "http://registry.cnpmjs.org/" scope = "" user-agent = "npm/6.14.13 node/v14.17.0 win32 x64" ; userconfig C:\Users\**\.npmrc registry = "http://registry.cnpmjs.org/" ; builtin config undefined prefix = "C:\\Users\\**\\AppData\\Roaming\\npm" ; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\Users\** ; HOME = C:\Users\** ; "npm config ls -l" to show all defaults.
以管理員身份啟動cmd,再次執行安裝依舊報錯:
C:\WINDOWS\system32>npm install --global --production windows-build-tools npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID npm ERR! errno ERR_TLS_CERT_ALTNAME_INVALID npm ERR! request to https://registry.cnpmjs.org/windows-build-tools failed, reason: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\**\AppData\Roaming\npm-cache\_logs\2021-05-23T14_54_03_162Z-debug.log
嘗試執行以下命令:
C:\WINDOWS\system32>npm set strict-ssl false C:\WINDOWS\system32>npm config set registry http://registry.npmjs.org/
參考路徑:npm 依賴下載報錯 Hostname/IP does not match certificate‘s 相關 解決方案_曉風攬月-CSDN博客
結果再次執行安裝,恢復原狀:
C:\WINDOWS\system32>npm install --global --production windows-build-tools npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to http://registry.npmjs.org/windows-build-tools failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org npm ERR! network This is a problem 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'
再次執行:
C:\WINDOWS\system32>npm config get proxy null C:\WINDOWS\system32>npm config get https-proxy null
兩次都得到null的結果后,再次安裝:
C:\WINDOWS\system32>npm install --global --production windows-build-tools npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported > windows-build-tools@5.2.2 postinstall C:\Users\**\AppData\Roaming\npm\node_modules\windows-build-tools > node ./dist/index.js Downloading python-2.7.15.amd64.msi [============================================>] 100.0% of 20.25 MB (9 MB/s) Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\**\.windows-build-tools\python-2.7.15.amd64.msi. Downloading vs_BuildTools.exe [============================================>] 100.0% of 1.12 MB (1.12 MB/s) Downloaded vs_BuildTools.exe. Saved to C:\Users\**\.windows-build-tools\vs_BuildTools.exe. Starting installation... Launched installers, now waiting for them to finish. This will likely take some time - please be patient! Status from the installers: ---------- Visual Studio Build Tools ---------- Still waiting for installer log file... ------------------- Python -------------------- Successfully installed Python 2.7
查看一下node和npm是否安裝成功:
C:\Users\**>node -v v14.17.0 C:\Users\**>npm -v 6.14.13
出現版本號,說明安裝成功。然后安裝mewman
C:\WINDOWS\system32>npm install -g newman npm WARN deprecated har-validator@5.1.5: this library is no longer supported C:\Users\**\AppData\Roaming\npm\newman -> C:\Users\**\AppData\Roaming\npm\node_modules\newman\bin\newman.js + newman@5.2.3 added 156 packages from 200 contributors in 64.98s C:\WINDOWS\system32>newman -v 5.2.3
安裝成功。
備注:
Windows下Node.js與npm的安裝與配置,參考路徑:
Windows下Node.js與npm的安裝與配置_TragueZw的博客-CSDN博客