smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.77k stars 2.79k forks source link

mime.lookup is not a function #4134

Closed ghost closed 6 years ago

ghost commented 6 years ago

my os is windows 8.1 64 bit this is the following error

CRASH: TypeError: mime.lookup is not a function
    at Server.respond (C:\Users\inky\Music\pokemon-showdown\node_modules\node-st
atic\lib\node-static.js:348:28)
    at C:\Users\inky\Music\pokemon-showdown\node_modules\node-static\lib\node-st
atic.js:64:22
    at FSReqWrap.oncomplete (fs.js:155:5)

Additional information:

here is the following logs

inky@Shousto4 MINGW64 ~/Music/pokemon-showdown (master)
$ node pokemon-showdown
NEW GLOBAL: global
NEW CHATROOM: lobby
NEW CHATROOM: staff
Worker 1 now listening on 0.0.0.0:8000
Test your server at http://localhost:8000

CRASH: TypeError: mime.lookup is not a function
    at Server.respond (C:\Users\inky\Music\pokemon-showdown\node_modules\node-st
atic\lib\node-static.js:348:28)
    at C:\Users\inky\Music\pokemon-showdown\node_modules\node-static\lib\node-st
atic.js:64:22
    at FSReqWrap.oncomplete (fs.js:155:5)

Additional information:

it happended when i went on http://localhost:8000

Zarel commented 6 years ago

My best guess is that this is a bug in node-static's Windows support?

Zarel commented 6 years ago

Looking further, it seems like either you're missing a subdependency, or you have the wrong version of mime.

Try deleting node_modules and trying again?

Zarel commented 6 years ago

(Feel free to reopen if that doesn't work)

ghost commented 6 years ago

@Zarel changing mime.lookup to mime.getType in the code worked so thanks anywayws, also restarting my computer also fixed it

Zarel commented 6 years ago

That definitely means you have the wrong version of mime. Are you using a third party npm implementation? The default one should install mime 1, not mime 2...

ghost commented 6 years ago

i just did npm install i belive npm is installing the lastest version but after i restarted my pc it stopped showing that error so i think its a web error or something

Zarel commented 6 years ago

Let's just chalk it up to a one-time npm glitch.

HoeenCoder commented 6 years ago

Are you using c9? I've expirienced this in the past trying to connect (link didnt redirect to psim.us) its easily fixed by adding -80.psim.us to the normal link (if it dosent already have it)

Morfent commented 6 years ago

What versions of node, npm, node-static, and mime are installed if this happens for you, out of curiosity?

Are you using c9? I've expirienced this in the past trying to connect (link didnt redirect to psim.us) its easily fixed by adding -80.psim.us to the normal link (if it dosent already have it)

The only reason that prevents the crash is because using the psim.us URL skips having to get index.html from the server to get redirected. Any requests to the server outside of /showdown/* should still crash

hawm commented 6 years ago

lookup() renamed to getType() in mime version 2. https://www.npmjs.com/package/mime