Nunjucks: Precompiled .js file throw `TypeError: runtime.fromIterator is not a function`

Created on 27 Mar 2018  路  4Comments  路  Source: mozilla/nunjucks

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?

Most helpful comment

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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Galfour picture Galfour  路  3Comments

sandiprb picture sandiprb  路  5Comments

ricordisamoa picture ricordisamoa  路  5Comments

kud picture kud  路  3Comments

sudhirbeldar picture sudhirbeldar  路  3Comments