sindresorhus/file-type

Cannot import the module

zlayine opened this issue · 2 comments

Hello,
I'm trying to use this library and when i try to import it i get this issue

image

here is the code i use

import { fileTypeFromFile } from 'file-type';

export default async function nameTest(file) {
    const type = await fileTypeFromFile(file);
    console.log(type);
}

Does anyone know what causing this issue

That method is only available on Node.js. You must ensure your bundler has the correct config.

In your tsconfig, you need

{
    "module: "node16",
    "moduleResolution": "node16"
}

or other node settings as specified on the typescript documentation