cannot use fileTypeFromBlob in next.js
joseph1125 opened this issue · 3 comments
joseph1125 commented
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?
sindresorhus commented
Blob
is supported as a global since Node.js 18, so we should really make it available in Node.js too.
sindresorhus commented
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.
katangafor commented
@sindresorhus What exactly should the project config specify? Just that the project code runs in a browser, so browser-only methods should be available?