sindresorhus/file-type

cannot use fileTypeFromBlob in next.js

joseph1125 opened this issue · 3 comments

I'm trying to use file-type in next.js as I want to check the input file user uploaded is correct. However, since the env is node (even though I'm writing for a react component) , I can't use "fileTypeFromBlob". Any workaround that I can use?

Blob is supported as a global since Node.js 18, so we should really make it available in Node.js too.

However, since the env is node (even though I'm writing for a react component) , I can't use "fileTypeFromBlob".

That sounds like a problem with your CRA/Webpack config and it's not something we can answer here.

@sindresorhus What exactly should the project config specify? Just that the project code runs in a browser, so browser-only methods should be available?