React app suddenly blank page - mime problem?

Viewed 418

My app suddenly gives a blank screen both in dev on local host (and on online version which worked the other day and has no changes made to it).

On console on local host: enter image description here

In error log in terminal:

.../node_modules/send/index.js:838
  var type = mime.lookup(path)
                  ^

TypeError: mime.lookup is not a function
    at SendStream.type (/Users/myname/Desktop/johannamuseet-app/node_modules/send/index.js:838:19)
    at SendStream.send (/Users/myname/Desktop/johannamuseet-app/node_modules/send/index.js:627:8)
    at onstat (/Users/myname/Desktop/johannamuseet-app/node_modules/send/index.js:729:10)

There was an error before this, that didn't allow to compile, after some research it seemed I should install @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining so I did. Then it worked to compile but now this next error occurs mentioned above.

I don't know what mime does. Nothing in my package.json indicates that it is a dependecy.

Any ideas would be much appreciated!

1 Answers

Wow this was annoying. I tried uninstalling send and mime and reinstalling them. Tried updating them. Even tried using the old version of mime. Still was getting errors. Finally went into the send package index.js and changed the code where it calls mime, to var type = mime.getType(path). But then you get another error because mime removed the charset method. So I had to change charset to var charset = 'utf8'. Obviously, this is a short-term fix. Send needs to update their package.

var type = mime.getType(path)

if (!type) {
  debug('no content-type')
  return
}

var charset = 'utf8'
//console.log(type)
//console.log(charset)
Related