sindresorhus / file-type

Detect the file type of a file, stream, or data
MIT License
3.71k stars 351 forks source link

strapi plugin - require() of ES Module not supported #583

Closed terchris closed 1 year ago

terchris commented 1 year ago

I'm working on a strapi.io plugin (typescript) and I would like to use the file-type. But when I'm trying the example "Determine file type from a Buffer, which may be a portion of the beginning of a file:" from the doc here it does not work. I get: .../strapi-server.js: require() of ES Module .../node_modules/file-type/index.js from ....myjsfile.js not supported. Instead change the require of index.js in ...myjsfile.js to a dynamic import() which is available in all CommonJS modules.

I'm not sure if I can change anything since my code runs as a plugin in strapi. And I have no desire to change the strapi code. Regards

sindresorhus commented 1 year ago

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c