Closed alain898 closed 2 months ago
I forgot pasting the test codes throwing error in file-type with version 19.4.0 and after, they are as followed:
import {fileTypeFromFile} from 'file-type'; console.log(await fileTypeFromFile('Unicorn.png'));
This problem is not related to this module.
You should not import {fileTypeFromFile}
in your render browser (read browser) as that is Node.js specific function. You should import and use that only in your main process.
Also so note that this package is (now) an ESM package. Your project needs to be ESM too. Read more.**
file-type cannot be imported in electron render process with nodeIntegration setted true after version 19.4.0 . and I've tried version 19.3.0 and before, these versions can work well.
when file-type with version 19.4.0 and after was imported in electron render process with nodeIntegration setted true, it throws following error:
ERROR in ./src/render/zzz.js 44:20-40 Module not found: Error: Package path . is not exported from package xxx\node_modules\file-type (see exports field in xxx\node_modules\file-type\package.json) @ ./src/xxx.js 7:20-49 @ ./src/yyy.js 34:22-55 @ ./src/render/index.js 12:24-55
webpack 5.93.0 compiled with 1 error in 3291 ms
and the node version is v20.15.1 as below, node -v v20.15.1
file-type with version 19.3.0 and before works well and everything is ok.