本人使用window10,再安装完node.js后安装http-server一直提示超时,出现如下页面
C:\Users\11967>npm install http-server -g
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/http-server failed, reason: connect ETIMEDOUT 104.16.18.35:443
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\11967\AppData\Roaming\npm-cache\_logs\2020-07-24T06_52_21_529Z-debug.log
使用该命令进行安装cnpm(npm/cnpm都是包管理工具,其中npm是国外版本,cnpm是国内版本
)也是不成功
C:\Users\11967>npm install -g cnpm
请教了前端的朋友,可以通过安装淘宝镜像再进行安装http-server
C:\Users\11967>npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\11967\AppData\Roaming\npm\cnpm -> C:\Users\11967\AppData\Roaming\npm\node_modules\cnpm\bin\cnpm
+ cnpm@6.1.1
added 16 packages from 2 contributors, removed 17 packages and updated 40 packages in 19.801s
C:\Users\11967>cnpm i -g http-server //安装http-server
安装成功后,进入你要选择的文件夹中打开命令窗口,执行http-server
就可以启动服务,使用ctrl+c
则是终止服务
网友评论