Skip to content

Node.js: file paths for load()/fetchFile, require('@ffmpeg/util') (#438, #426, #497) - #956

Draft
lucasgelfond wants to merge 1 commit into
claude/06-nodefrom
claude/07-node-paths
Draft

lucasgelfond wants to merge 1 commit into
claude/06-nodefrom
claude/07-node-paths

Conversation

@lucasgelfond

@lucasgelfond lucasgelfond commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

The other long-standing Node bug family (#438 "Support for Node.js v18", #426, #497): the library assumes URLs, but in Node people pass file paths, so you got TypeError: fetch failed or Failed to parse URL from …/ffmpeg-core.wasm.

  • load() accepts filesystem paths (including Windows paths) for coreURL/wasmURL, converting them to file: URLs before import() and emscripten see them. POSIX absolute paths already happened to work through Node's import(); Windows paths and wasmURL did not.
  • @ffmpeg/util gets a node export. Its fetchFile() reads local paths and file: URLs from disk, and reads Blobs without FileReader, which Node doesn't have. URLs still go through fetch.
  • require('@ffmpeg/util') has never worked in Node. The package is "type": "module", so dist/cjs/*.js was parsed as ESM. dist/cjs is now marked "type": "commonjs".

Verification: tests/node/paths.test.mjs covers path coreURL, fetchFile with a path, file: string, URL object and Blob, CJS require, and an end-to-end transcode of a file read that way. All 12 Node tests pass.

Addresses

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for ffmpegwasm failed.

Name Link
🔨 Latest commit 8db13c9
🔍 Latest deploy log https://app.netlify.com/projects/ffmpegwasm/deploys/6abbd097a0bdad000900ad79

In Node.js, ffmpeg.wasm was handed file paths where it expected URLs, and
fetch() can't read them ("TypeError: fetch failed", "Failed to parse URL
from .../ffmpeg-core.wasm": #438, #426, #497).

- load(): coreURL and wasmURL may be file paths, including Windows ones;
  they become file: URLs before import() and emscripten see them.
- @ffmpeg/util gets a "node" export whose fetchFile() reads local paths and
  file: URLs from disk, and Blobs without FileReader (Node has none).
- require('@ffmpeg/util') never worked in Node: the package is
  "type": "module", so dist/cjs was parsed as ESM. dist/cjs is now marked
  "type": "commonjs".
- tests/node/paths.test.mjs covers all of the above.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant