I have tried precompile .njk file to .js file by gulp-nunjucks , it works. but when I load the precompiled .js into my page and execute it, an error occurs:
TypeError: runtime.fromIterator is not a function
I made a breakpoint to debug, I can not find fromIterator on runtime definitely. and I tried to search fromIterator in nunjucks' source code but also can't find it.
so why the precompiled .js has the call of fromIterator, the error sentence was :
t_3 = runtime.fromIterator(t_3);
if I just delete this line, all code run good.
can anybody help me?
I even tried search the error on google but got nothing about it. how Strange! Am I the only one who meet this problem?
I suspect it's a version incompatibility. runtime.fromIterator was introduced in 3.1.0. I suspect that gulp-nunjucks is precompiling with 3.1.x, but your nunjucks package is 3.0.x.
@fdintino Exactly! You are right!
I just load the nunjucks from it's official website:
<script src="https://mozilla.github.io/nunjucks/files/nunjucks-slim.js"></script>
but I got the above error. From your reminding, I copyed a nunjucks-sim.js from node_modules and replaced the remote one, it now works without error!
thank you.
but why the https://mozilla.github.io/nunjucks/files/nunjucks-slim.js is NOT the latest version? it's confusing.
I've updated the nunjucks library on mozilla.github.io to the latest version.
Most helpful comment
I suspect it's a version incompatibility.
runtime.fromIteratorwas introduced in 3.1.0. I suspect that gulp-nunjucks is precompiling with 3.1.x, but your nunjucks package is 3.0.x.