expressjs / serve-static

Serve static files
MIT License
1.38k stars 227 forks source link

error TS2688: Cannot find type definition file for 'mime'. #162

Closed porameht closed 4 months ago

porameht commented 4 months ago

I keep getting this error on "npm run build"

Screenshot 2567-04-01 at 11 17 17

Node version : 16

Screenshot 2567-04-01 at 11 17 10

How can I resolve this conflict and ensure I have the correct type definitions for the versions of 'mime' being used? Is there a specific way to manage multiple versions of 'mime' and their type definitions?

the-1aw commented 4 months ago

Not sure what happened but it looks like mime's type definitions were deprecated through 4.0.0

In case it can help, I ended up using package.json resolution as a workaround.

"resolutions": {
    "@types/mime": "^3 || ^1"
},
jonchurch commented 4 months ago

Just ran into this at work and remembered seeing this issue.

It appears that @types/mime@4.0.0 is deprecated now. I dont know why yet, the message on NPM says that mime ships it's own types now. https://www.npmjs.com/package/@types/mime

I'll keep this open for now bc folks will likely come looking, but there isn't anything we can do over here, it's an upstream issue.

jonchurch commented 4 months ago

This should be resolved with https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69231

Closing, let me know if something goes awry.