Problems using Handlebars.compile

Refresh

December 2018

Views

1.8k time

2

I've trying to get handlebar to install for precompiling templates. I've followed the installation instructions (http://handlebarsjs.com/precompilation.html), and I do not appear to have any problem running the installation (see below). However when I issue the compile command ...

handlebars users.handlebars -f templates.js

the handlebars command can not be found.

-bash: handlebars: command not found

Would love to get a clue on this one.

(username) ~$ which npm
/usr/local/bin/npm
(username) ~$ which node
/usr/local/bin/node
(username) ~$ npm install -g handlebars
npm http GET https://registry.npmjs.org/handlebars
npm http 304 https://registry.npmjs.org/handlebars
npm http GET https://registry.npmjs.org/uglify-js
npm http GET https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/uglify-js
npm http 304 https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/wordwrap
/usr/local/share/npm/bin/handlebars -> /usr/local/share/npm/lib/node_modules/handlebars/bin/handlebars
[email protected] /usr/local/share/npm/lib/node_modules/handlebars
├── [email protected]
└── [email protected] ([email protected])
(username) ~$ cd Sites/projectone/templates/
(username) ~/Sites/projectone/templates (master)$ ll
total 8
drwxr-xr-x   3 username  ec_earth  102 Sep 26 23:57 .
drwxr-xr-x  10 username  ec_earth  340 Sep 26 23:58 ..
-rw-r--r--   1 username  ec_earth   17 Sep 26 23:57 users.handlebars
(username) ~/Sites/projectone/templates (master)$ handlebars users.handlebars -f templates.js
-bash: handlebars: command not found

1 answers

2

Вы должны использовать полный путь к node_modules/.binдиректории (они не будут автоматически добавлены в путь).

/usr/local/share/npm/lib/node_modules/.bin/handlebars users.handlebars -f template.js