简体   繁体   中英

'Blob is not defined' error in async-array-buffer. How to fix it?

I'm getting error when trying start SSR and import { AudioContext } from standardized-audio-context

/workspace/node_modules/async-array-buffer/build/es5/bundle.js:10
    var blob = new Blob([worker], {
               ^

ReferenceError: Blob is not defined
    at /workspace/node_modules/async-array-buffer/build/es5/bundle.js:10:13
    at /workspace/node_modules/async-array-buffer/build/es5/bundle.js:2:65
    at Object.<anonymous> (/workspace/node_modules/async-array-buffer/build/es5/bundle.js:5:2)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/workspace/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/workspace/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
error Command failed with exit code 1.

How to possible to fix and where i need start to dig?

First of all, install the below package

-> npm install blob-polyfill

After that go to server.ts file, make an import and add blob to global.

-> import { Blob } from 'blob-polyfill'

-> global['Blob'] = Blob

I guess now you are all set to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM