Error: Cannot find module 'mime-types'

I have a project in Node.js that I’ve been gradually tinkering with for months now. Everything has worked fine up until now. I was editing my watch.json file when I accidentally set “watch.json” as an “exclude” file, before deleting that line. I don’t know if that’s what caused the problem, but that’s what I did right before it started happening.

I got an error stating that it couldn’t find a module “mime-types”. I haven’t referenced “mime-types” anywhere in my code, but I installed the module into package.json after the error. During installation, I got a NPM message in my console stating it was performing a “headless installation” and a string of warnings that it failed to find files. From there on out, the problem has persisted and I’ve been unable to resolve it.

Google searches revealed a similar issue with a “mime” module, but installation fixed that problem.

My program is fearless-degree.

hi @fin444 - i remixed your app and was able to reproduce the same error! what i did to get the app work again was open the console and run enable-npm so that i had a clean slate for my packages and then the app worked. i then ran enable-pnpm so that my packages didn’t count towards my disk space. if you try that, does the app work for you? i’m not sure why this error was happening in the first place, but it’s not uncommon for node package installation to have hiccups.

3 Likes

That worked, thanks!