2012-09-27 63 views
2

我试图去安装预编译模板的句柄。我遵循安装说明(http://handlebarsjs.com/precompilation.html),并且我似乎没有任何问题运行安装(见下文)。但是,当我发出编译命令...使用Handlebars.compile时出现的问题

handlebars users.handlebars -f templates.js 

无法找到handlebars命令。

-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 
[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 

回答

2

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

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

亲爱的@Bill我有一个非常类似的问题。但我似乎无法找到正确的道路。我有'c:\ users \ b \ downloads \ node-v7.1.0-win-x64 \ node_modules'然后我有两个可能的文件夹'handlebars'和'npm'。在里面,我有'node_modules/.bin'的把手,但是里面没有'handlebars' ...有什么帮助吗?谢谢 –