Skip to content

caught ReferenceError: global is not defined #2

@bjornharvold

Description

@bjornharvold

Great library!

For some reason, today ng-qrcode failed with a big fat error.

Uncaught ReferenceError: global is not defined
    at Object.../../node_modules/node-libs-browser/node_modules/buffer/index.js (index.js:43)
    at __webpack_require__ (bootstrap:79)
    at Object.../../node_modules/qrcode/lib/core/reed-solomon-encoder.js (reed-solomon-encoder.js:3)
    at __webpack_require__ (bootstrap:79)
    at Object.../../node_modules/qrcode/lib/core/qrcode.js (qrcode.js:10)
    at __webpack_require__ (bootstrap:79)
    at Object.../../node_modules/qrcode/lib/browser.js (browser.js:4)
    at __webpack_require__ (bootstrap:79)
    at Module.../../node_modules/ng-qrcode/fesm2015/ng-qrcode.js (ng-qrcode.js:1)

I did some Googling and found:
global is not available as of Angular 6.

Library authors should not depend on this property. See this post: angular/angular-cli#9827 (comment)

As a workaround for now, I am putting this is my polyfills.ts
(window as any).global = window;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions