Javascript 使用Handlebar.compile时出现的问题

Javascript 使用Handlebar.compile时出现的问题,javascript,node.js,handlebars.js,Javascript,Node.js,Handlebars.js,我正在尝试让handlebar安装预编译模板。我已经按照安装说明进行了操作(http://handlebarsjs.com/precompilation.html),并且我在运行安装时似乎没有任何问题(请参见下文)。但是,当我发出compile命令时 handlebars users.handlebars -f templates.js 找不到“把手”命令 -bash: handlebars: command not found 我很想知道这件事的线索 (username) ~$ which

我正在尝试让handlebar安装预编译模板。我已经按照安装说明进行了操作(http://handlebarsjs.com/precompilation.html),并且我在运行安装时似乎没有任何问题(请参见下文)。但是,当我发出compile命令时

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

您需要使用
节点\u modules/.bin
目录的完整路径(它们不会自动添加到您的路径中)


亲爱的@Bill我也有一个非常类似的问题。但我似乎找不到正确的道路。我拥有的是
c:\users\b\downloads\node-v7.1.0-win-x64\node\u模块
,然后我有两个可能的文件夹
handlebar
npm
。在里面,车把我有
node\u modules/.bin
,但是里面没有
handlebar
。。。有什么帮助吗?谢谢
/usr/local/share/npm/lib/node_modules/.bin/handlebars users.handlebars -f template.js