首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用http-server激活服务器得到TypeError: Readable.from不是函数

使用http-server激活服务器得到TypeError: Readable.from不是函数
EN

Stack Overflow用户
提问于 2021-10-21 06:56:15
回答 1查看 2.6K关注 0票数 6

我目前正在将pwa添加到我的新angular项目中。

C:\Users\alan_yu\angular-pwa>http服务器-p 8080 -c-1 dist/angular-pwa

代码语言:javascript
复制
Starting up http-server, serving dist/angular-pwa

http-server version: 14.0.0

http-server settings: 
CORS: disabled
Cache: -1 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://192.168.16.91:8080
  http://192.168.56.1:8080
  http://192.168.99.1:8080
  http://127.0.0.1:8080
Hit CTRL-C to stop the server

但是在加载网页后,我在控制台中得到了错误:

代码语言:javascript
复制
[2021-10-21T06:51:39.582Z]  "GET /" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"
(node:11416) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
C:\Users\alan_yu\AppData\Roaming\npm\node_modules\http-server\lib\core\index.js:246
          stream = Readable.from(bytes)
                            ^

TypeError: Readable.from is not a function
    at serve (C:\Users\alan_yu\AppData\Roaming\npm\node_modules\http-server\lib\core\index.js:246:29)
    at C:\Users\alan_yu\AppData\Roaming\npm\node_modules\http-server\lib\core\index.js:419:13
    at FSReqCallback.oncomplete (fs.js:149:5)

环境版本

操作系统类型: Windows 7专业版

节点版本: V12.2.0

http-服务器版本: V14.0.0

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-26 01:45:09

我也在gihub中询问,然后我得到了答案。

将节点更新到v13.13.0 (至少是v12.3.1)后,http-server工作正常

https://nodejs.org/docs/latest-v12.x/api/stream.html#stream_stream_readable_from_iterable_options

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69657263

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档