webrtc error with mime.lookup

Viewed 10463

I tried webrtc demo on my PC. but in demo step-04. When I use npm install and node index.js,it shows "TypeError: mime.lookup is not a function".

even after I installed mime by typing "npm install mime"

How can I fix this and make the demo work?

7 Answers
use mime-type instead of mime. So, Install mime-types first:
    npm install mime-types
then make change in your code:
    var mime=require('mime-types');

I'm having the same issue with step 4. You can changing the node-static version from 0.7.7 to 0.7.10 in package.json and rerunning npm install

  "dependencies": {
    "node-static": "0.7.10",
    "socket.io": "1.2.0" }

if you have a folder "node modules" in your root directory,delete that and type npm cache clear and then type npm install.this should work fine

change mime.lookup(type) to mime.getType(type)

As @HRISHABH RAJ mentioned you want to reference mime-type instead of mime however you should check your node_modules folder first to see if the package is already installed.

Try deleting node_modules and running npm i and npm start.

If the problem still exists try doing npm update --legacy-peer-deps and rerun your application.

Related