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的安装与配置_TragueZw的博客-CSDN博客
原文:https://www.cnblogs.com/puge-wh/p/14802529.html