pillarjs / send

Streaming static file server with Range and conditional-GET support
MIT License
798 stars 191 forks source link

lookup not a function #200

Closed WilliamRagstad closed 3 years ago

WilliamRagstad commented 3 years ago

I get the error:

C:\Users\willi\odrive\Google Drive\- KTH\- Kurser\Termin 2\DH2642 Interaktionsprogrammering och dynamiska webben\Projekt\DH2642-Project\node_modules\send\index.js:840
  var type = mime.lookup(path)
                  ^

TypeError: mime.lookup is not a function
    at SendStream.type (C:\Users\willi\odrive\Google Drive\- KTH\- Kurser\Termin 2\DH2642 Interaktionsprogrammering och dynamiska webben\Projekt\DH2642-Project\node_modules\send\index.js:840:19)
    at SendStream.send (C:\Users\willi\odrive\Google Drive\- KTH\- Kurser\Termin 2\DH2642 Interaktionsprogrammering och dynamiska webben\Projekt\DH2642-Project\node_modules\send\index.js:627:8) 
    at onstat (C:\Users\willi\odrive\Google Drive\- KTH\- Kurser\Termin 2\DH2642 Interaktionsprogrammering och dynamiska webben\Projekt\DH2642-Project\node_modules\send\index.js:729:10)
    at FSReqCallback.oncomplete (node:fs:192:5)

On this location https://github.com/pillarjs/send/blob/de073ed3237ade9ff71c61673a34474b30e5d45b/index.js#L838

Please change to:

var type;
if (mime.lookup) type = mime.lookup(path)
dougwilson commented 3 years ago

Hi @WilliamRagstad you likely have a node_modules folder that is not correct. You can delete it and run npm install again to fix it, and run npm ls to look for any errors about bad dependencies.

To serve static files the type needs to be there, and if you don't want to use the automatic type lookup, if you set the content-type header yourself, this module will not attempt to look up the type.