diff --git a/package.json b/package.json index 7d8014a..d2fa49f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "wait": "rimraf dist && wait-on http://localhost:3000/dist/ffmpeg.dev.js", "test": "npm-run-all -p -r start test:all", "test:all": "npm-run-all wait test:browser:ffmpeg test:node:all", - "test:node": "node --experimental-wasm-threads --experimental-wasm-bulk-memory node_modules/.bin/_mocha --exit --bail --require ./scripts/test-helper.js", + "test:node": "node node_modules/mocha/bin/_mocha --exit --bail --require ./scripts/test-helper.js", "test:node:all": "npm run test:node -- ./tests/*.test.js", "test:browser": "mocha-headless-chrome -a allow-file-access-from-files -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000", "test:browser:ffmpeg": "npm run test:browser -- -f ./tests/ffmpeg.test.html" diff --git a/src/createFFmpeg.js b/src/createFFmpeg.js index 61753ff..55240a6 100644 --- a/src/createFFmpeg.js +++ b/src/createFFmpeg.js @@ -75,14 +75,17 @@ module.exports = (_options = {}) => { * as we are using blob URL instead of original URL to avoid cross origin issues. */ locateFile: (path, prefix) => { - if (typeof wasmPath !== 'undefined' - && path.endsWith('ffmpeg-core.wasm')) { - return wasmPath; - } - if (typeof workerPath !== 'undefined' - && path.endsWith('ffmpeg-core.worker.js')) { - return workerPath; + if (typeof window !== 'undefined' || typeof WorkerGlobalScope !== 'undefined') { + if (typeof wasmPath !== 'undefined' + && path.endsWith('ffmpeg-core.wasm')) { + return wasmPath; + } + if (typeof workerPath !== 'undefined' + && path.endsWith('ffmpeg-core.worker.js')) { + return workerPath; + } } + return prefix + path; }, }); ffmpeg = Core.cwrap('proxy_main', 'number', ['number', 'number']);