2012-09-27 97 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' ...有什麼幫助嗎?謝謝 –