ffmpeg.wasm
ffmpeg.wasm copied to clipboard
Added type=module to @ffmpeg/util package.json
I'm using Vite and pnpm and when trying to use @ffmpeg/util I'm getting this error:
import { ERROR_RESPONSE_BODY_READER, ERROR_INCOMPLETED_DOWNLOAD, } from "./errors.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Adding "type": "module" to @ffmpeg/util's package.json fixes the error 👍
Deploy Preview for ffmpegwasm canceled.
| Name | Link |
|---|---|
| Latest commit | d76af5691716b3d28c5e38f3b0734f5a5248d05d |
| Latest deploy log | https://app.netlify.com/sites/ffmpegwasm/deploys/6550a9f339a8440008200adb |
Just a little +1 from me. I'm seeing the same error when using Remix.
I ran into the same problem. If you need a work around, this is what worked for me.
- Install
patch-package
npm install patch-package --save -dev
- Add
postinstallscript topackage.json
// package.json
"scripts": {
...
"postinstall": "patch-package"
},
- Run
patch-packagewith the--excludeflag
npx patch-package --exclude 'nothing' @ffmpeg/util
- Commit the changes
You should then see a new
.patchfile is created in/patches
E.g
// @ffmpeg+util+0.12.1.patch
diff --git a/node_modules/@ffmpeg/util/package.json b/node_modules/@ffmpeg/util/package.json
index 3afedb4..0a48d3a 100644
--- a/node_modules/@ffmpeg/util/package.json
+++ b/node_modules/@ffmpeg/util/package.json
@@ -3,6 +3,7 @@
"version": "0.12.1",
"description": "browser utils for @ffmpeg/*",
"main": "./dist/cjs/index.js",
+ "type": "module",
"types": "./dist/cjs/index.d.ts",
"exports": {
".": {
Hope that helps someone!