3

我试图让车把安装用于预编译模板。我已按照安装说明 (http://handlebarsjs.com/precompilation.html),运行安装似乎没有任何问题(见下文)。但是,当我发出编译命令时...

handlebars users.handlebars -f templates.js

找不到车把命令。

-bash: handlebars: command not found

很想知道这个。

(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
handlebars@1.0.7 /usr/local/share/npm/lib/node_modules/handlebars
├── uglify-js@1.2.6
└── optimist@0.3.4 (wordwrap@0.0.2)
(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
4

1 回答 1

2

您需要使用node_modules/.bin目录的完整路径(它们不会自动添加到您的路径中)。

/usr/local/share/npm/lib/node_modules/.bin/handlebars users.handlebars -f template.js
于 2012-09-27T15:47:11.950 回答