Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Mime.extension and Mime.lookup is not a function #135

Open
sugizo opened this issue Nov 4, 2017 · 2 comments
Open

Mime.extension and Mime.lookup is not a function #135

sugizo opened this issue Nov 4, 2017 · 2 comments

Comments

@sugizo
Copy link

sugizo commented Nov 4, 2017

$ node -v
v6.11.2
$ npm -v
3.10.10
$ ../node_modules/.bin/punch v
Punch version 0.5.46
$ ../node_modules/.bin/punch s
Running Punch server on localhost:9009
TypeError: Mime.extension is not a function
at Object.getExtension (/Users/sugizo/test/js/learn/node_modules/punch/lib/utils/path_utils.js:18:43)
at Object.handle (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:238:34)
at Object.handle (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:31:16)
at next (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:169:15)
at Object.compression [as handle] (/Users/sugizo/test/js/learn/node_modules/compression/index.js:216:5)
at next (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:169:15)
at Object.cookieParser [as handle] (/Users/sugizo/test/js/learn/node_modules/cookie-parser/index.js:48:5)
at next (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:169:15)
at Object.middleware [as handle] (/Users/sugizo/test/js/learn/node_modules/http-accept/lib/Accept.js:322:10)
at next (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:169:15)
at Object.logger (/Users/sugizo/test/js/learn/node_modules/morgan/index.js:108:5)
at next (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:169:15)
at Function.app.handle (/Users/sugizo/test/js/learn/node_modules/connect/lib/proto.js:177:3)
at Server.app (/Users/sugizo/test/js/learn/node_modules/connect/lib/connect.js:66:37)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

127.0.0.1 - GET / HTTP/1.1 500 - - 23.493 ms
connect deprecated utils.conditionalGET: use fresh module directly ../node_modules/punch/lib/page_server.js:158:20
/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:50
var content_type = Mime.lookup(file_extension);
^

TypeError: Mime.lookup is not a function
at Object.setContentType (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:50:28)
at Object.prepareCachedResponse (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:145:8)
at /Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:225:19
at Object.validatePublicCache (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:172:11)
at /Users/sugizo/test/js/learn/node_modules/punch/lib/page_server.js:223:18
at callback_handler (/Users/sugizo/test/js/learn/node_modules/punch/lib/page_renderer.js:218:13)
at /Users/sugizo/test/js/learn/node_modules/punch/lib/page_renderer.js:91:12
at /Users/sugizo/test/js/learn/node_modules/punch/lib/template_handler.js:55:11
at FSReqWrap.oncomplete (fs.js:123:15)

@broofa
Copy link

broofa commented Jan 12, 2018

This is because mime (and other modules) in package.json have ">=" version options... and the API for mime changed between v1 and v2.

(And this is why you should never use ">=" in package.json :-/)

@sugizo
Copy link
Author

sugizo commented Jan 12, 2018

pardon, forget to add the detail step to produce the error above :
npm install punch
./node_modules/.bin/punch setup mysite
cd mysite
../node_modules/.bin/punch s
open http://localhost:9009

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants