Reputation: 20730
I have been using handlebars.js client-side for a while, and I wanted to get into using pre-compiled templates. I followed the general instructions I could find on the web, including installing it on Node.js:
npm install handlebars -g
Next, I go to my Node.js directory and try to compile a simple template:
handlebars test.handlebars -f test.js
And I get an error (command prompt, mind you and i'm sorry):
C:\Users\Administrator\AppData\Roaming\npm\node_modules\handlebars\lib\handlebars.js:1
(function (exports, require, module, __filename, __dirname) { import Handlebar
^^^^^^
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\handlebars\bin\handlebars:105:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
I go to this handlebars.js file that errored and sure enough the code definitely doesn't look like javascript:
import Handlebars from "./handlebars.runtime";
// Compiler imports
module AST from "./handlebars/compiler/ast";
import { parser as Parser, parse } from "./handlebars/compiler/base";
// ... etc.
I don't really know what this is, so I don't know what I did wrong or what my problem is.
Upvotes: 3
Views: 2057
Reputation: 1103
Looks like lib folder contains not processed ES6-like modules. So probably it was be not processed with es6-module-transpiler. I'm open issue https://github.com/wycats/handlebars.js/issues/642 also exist similar issue https://github.com/wycats/handlebars.js/issues/643 .
I'm workaround this by installing es6-module-transpiler manually process files, and quick fix remain errors (something around with ["default"] exports).
Upvotes: 3