Problems using Handlebars.compile


December 2018


1.8k time


I've trying to get handlebar to install for precompiling templates. I've followed the installation instructions (, 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
(username) ~$ which node
(username) ~$ npm install -g handlebars
npm http GET
npm http 304
npm http GET
npm http GET
npm http 304
npm http 304
npm http GET
npm http 304
/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


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

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