Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using http-server to activate server got TypeError: Readable.from is not a function

Im currently adding pwa to my new angular project.

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

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

But I got the errors in the console after loading the webpage:

[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)

Environment Versions

OS Type: Windows 7 Pro

Node version: V12.2.0

http-server version: V14.0.0

like image 841
Alan Yu Avatar asked Oct 21 '21 06:10

Alan Yu


1 Answers

stream.Readable.from function added in: node v12.3.0, v10.17.0

After updating node from V12.2.0 to v13.13.0 (at least v12.3.0), the http-server works well.

Ref: Node.js doc

like image 77
Alan Yu Avatar answered Nov 02 '22 22:11

Alan Yu