You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use file-type in a Vite project, but I keep running into errors:
> ../../node_modules/file-type/browser.js:1:21: error: Could not resolve "node:buffer" (mark it as external to exclude it from the bundle)
1 │ import {Buffer} from 'node:buffer';
╵ ~~~~~~~~~~~~~
> ../../node_modules/file-type/core.js:1:21: error: Could not resolve "node:buffer" (mark it as external to exclude it from the bundle)
1 │ import {Buffer} from 'node:buffer';
╵ ~~~~~~~~~~~~~
> ../../node_modules/file-type/core.js:1489:40: error: Could not resolve "node:stream" (mark it as external to exclude it from the bundle, or add ".catch()" to handle the failure at run-time)
1489 │ const {default: stream} = await import('node:stream');
╵ ~~~~~~~~~~~~~
error when starting dev server:
Error: Build failed with 3 errors:
../../node_modules/file-type/browser.js:1:21: error: Could not resolve "node:buffer" (mark it as external to exclude it from the bundle)
../../node_modules/file-type/core.js:1:21: error: Could not resolve "node:buffer" (mark it as external to exclude it from the bundle)
../../node_modules/file-type/core.js:1489:40: error: Could not resolve "node:stream" (mark it as external to exclude it from the bundle, or add ".catch()" to handle the failure at run-time)
at failureErrorWithLog (/Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:1493:15)
at /Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:1151:28
at runOnEndCallbacks (/Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:941:63)
at buildResponseToResult (/Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:1149:7)
at /Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:1258:14
at /Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:629:9
at handleIncomingPacket (/Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/Users/pastelmind/my-project/node_modules/esbuild/lib/main.js:596:7)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
I also tried importing fileTypeFromBuffer(), but ran into the same errors.
How do I bundle this for web browsers using Vite.js?
The text was updated successfully, but these errors were encountered:
I'm trying to use file-type in a Vite project, but I keep running into errors:
I also tried importing
fileTypeFromBuffer()
, but ran into the same errors.How do I bundle this for web browsers using Vite.js?
The text was updated successfully, but these errors were encountered: