Cannot read property 'MutationObserver' of undefined
See original GitHub issuenunjucks=2.0.3
node=4.0.0
webpack=1.12.2
Getting an error when importing nunjucks:
Uncaught TypeError: Cannot read property 'MutationObserver' of undefined
looks like this bit of code is triggering it:
var BrowserMutationObserver=global.MutationObserver || global.WebKitMutationObserver;
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Cannot read function of undefined - jquery - Stack Overflow
1 Answer 1 ... mutationLists is a property of $.event.special.changeElement which is a function. Having properties as functions of an object acts ...
Read more >Uncaught TypeError: Cannot read property '$el' of undefined
I'm open to any suggestions. Uncaught TypeError: Cannot read property '$el' of undefined at e.handler (uikit.min.js:3) at uikit ...
Read more >Cannot read property 'MutationObserver' of undefined?
uni-app,mui,nativejs,dcloud,HBuilder,HBuilderX,HTML5,流应用,数字天堂网络,数字天堂,web,前端开发,web开发,跨平台,开发工具,ide,css,javascript.
Read more >MutationObserver.takeRecords() - Web APIs | MDN
The MutationObserver method takeRecords() returns a list of all matching DOM changes that have been detected but not yet processed by the ...
Read more >Error "Cannot read properties of null (reading 'ActivityLogs ...
I'm having lots or problems deploying one of our projects to the TEST environment/server. Other projects are working fine including ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a workaround, you could use string-replace-webpack-plugin and the following in webpack.config.js. Not ideal but it works:
I’ve looked into it more closely, and I think you are mistaken. This was fixed in asap 2.0.5 (https://github.com/kriskowal/asap/commit/c5b65d2c0a7dd62c0bd11990b8531f50290072ca), and that fix has been bundled with nunjucks since v3.0.1 (see here). Here it is in the 3.2.0 release:
https://github.com/mozilla/nunjucks/blob/d0ab8d6bf4d7b91fb2c2883f95b172f776d4e531/files/nunjucks-slim.js#L2032-L2033
(In a browser,
self
in the global scope returnswindow
(MDN Window.self).There are two possibilities: either you are using Nunjucks 2.x, or you have an old version of asap installed in your own project, and rollup is bundling that.
My motivation for investigating further is that I have been using nunjucks with rollup since 2017, when I took on maintenance of this project (and when 3.0.1 was released), and I’ve never needed a workaround.