handlebars 安装erro


handlebars 安装: html

一、npm node

二、npm  install -g handlebars(后面能够加@3.0.1版本号) npm

三、handlebars public/js/template > public/js/template.js 在相应目录进行预编译 windows

事先肯定你的电脑上已经安装了node.js 函数

而后根据npm install -g handlebars 命令安装handlebars ui

此时我碰到了一个问题: this

    虽然提示handlebars安装成功,windows+r>>>>cmd>>>>handlebars>提示'handlebars'不是内部或外部命令,也不是可运行的程序 或批处理  spa

    因而我查了不少资料,发现出现该命令的可能缘由是由于么有设置环境变量。 .net

    当我在用户环境变量中添加   C:\Program Files\nodejs\;(node.js安装路径),并无成功。 htm

    最后终于获得了一个解决办法:

        是这么解决的, 环境变量增长NODE_PATH  C:\Users\xxx\AppData\Roaming\npm\ 而后PATH里最后加上%NODE_PATH%

    如今终于在命令框中属于handlebars提示了:


        Microsoft Windows [版本 6.3.9600]
        (c) 2013 Microsoft Corporation。保留全部权利。


        C:\Users\huainanhai>handlebars
        Precompile handlebar templates.
        Usage: node C:\Users\huainanhai\AppData\Roaming\npm\node_modules\handlebars\bin\
        handlebars [template|directory]...


        Options:
          -f, --output         Output File


          --map                Source Map File
               [string]  [default: undefined]
          -a, --amd            Exports amd style (require.js)


          -c, --commonjs       Exports CommonJS style, path to Handlebars module
               [default: null]
          -h, --handlebarPath  Path to handlebar.js (only valid for amd-style)
               [default: ""]
          -k, --known          Known helpers


          -o, --knownOnly      Known helpers only


          -m, --min            Minimize output


          -n, --namespace      Template namespace
               [default: "Handlebars.templates"]
          -s, --simple         Output template function only.


          -r, --root           Template root. Base value that will be stripped from temp
            late names.
          -p, --partial        Compiling a partial template


          -d, --data           Include data when compiling


          -e, --extension      Template extension.
               [default: "handlebars"]
          -b, --bom            Removes the BOM (Byte Order Mark) from the beginning of t
        he templates.
          -v, --version        Prints the current compiler version


          --help               Outputs this message

      到如今为止 handlebars 算做安装完成   

        C:\Users\huainanhai>handlebars -v
        4.0.5

        但是当我使用命令编译template文件夹后生成了template.js文件 运行后发现提示handlebars的函数出现问题,非常头疼,编译出来的内容不正常,后来又展转得知多是handlebars版本问题 须要安装handlebars 3.0.1 版本才能够,使用命令 npm install -g handlebars@3.0.1

        C:\Users\huainanhai>handlebars -v
        3.0.1

        此刻再次编译template文件 运行html页面,页面显示无误,终于完成了!

        以上内容纯属原创,若有转载,请标明出处!

        本文地址:http://my.oschina.net/u/2508830/blog/536258

相关文章
相关标签/搜索