vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 680 forks source link

nunjucks Unexpected token ILLEGAL #248

Closed huguangju closed 8 years ago

huguangju commented 8 years ago

reported error:

gulp-notify: [Error running Gulp] SyntaxError in plugin 'gulp-nunjucks'
Unexpected token ILLEGAL
/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/ttf2woff2/jssrc/ttf2woff2.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB;var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFile

Template render error: (unknown path)
  TypeError: must start with number, buffer, array or string
    at Object.exports.withPrettyErrors (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/nunjucks/src/lib.js:33:17)
    at Obj.extend.render (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/nunjucks/src/environment.js:344:20)
    at Obj.extend.renderString (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/nunjucks/src/environment.js:231:21)
    at Object.module.exports.renderString (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/nunjucks/index.js:66:14)
    at Transform._transform (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/index.js:29:18)
    at Transform._read (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Transform._write (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at Transform.Writable.write (/Users/hugo/programming/github/node-resources/gulp-starter/node_modules/gulp-nunjucks-render/node_modules/readable-stream/lib/_stream_writable.js:194:11)

I just add a paragraph in index.html like below, and run gulp production:

{% block content %}
   ... ...
  <h4>RMA Procedures</h4>

  Sales invoices and packing lists in order for us to obtain the detailed information of the relevant goods from our quality control database.

{% endblock %}
greypants commented 8 years ago

Hmm... Maybe related to https://github.com/vigetlabs/gulp-starter/issues/249

Feel like ttf2woff2 has been problematic. Try removing woff2 from the iconFont config extensions list, upgrading gulp-iconfont, or removing the iconfont config all together. I've been using SVG sprites instead for a while now.

greypants commented 8 years ago

Weird that it's throwing an error in Nunjucks though.

huguangju commented 8 years ago

No matter upgraded gulp-iconfont, removing woff2 from config extensions list or removed all iconfont config, it's also reported error.

After upgraded gulp-iconfont to 6.0.0, it reproted:

Error in plugin 'svgicons2svgfont'
Message:
    The "appendUnicode" option were renamed "prependUnicode". See https://github.com/nfroidure/gulp-svgicons2svgfont/issues/33
huguangju commented 8 years ago

Maybe it is cause by Unicode Character 'LINE SEPARATOR' (U+2028), Javascript parse error on '\u2028' unicode character , can saw it in git diff: qq20160225-0 mozilla/nunjucks#126

greypants commented 8 years ago

I think this may be fixed by #256

@huguangju Can you pull the latest from master and confirm?

greypants commented 8 years ago

Also fixed the upgrade issue you mentioned with #258

Closing this, but please re-open if you're still having issues.

huguangju commented 8 years ago

After removed Unicode Line Separator in Bash u2028, this end up worked

# http://stackoverflow.com/a/16552635/4723163
sed -i.old $'s/\xE2\x80\xA8/ /g' inFile