2

I am trying to create a Node.JS app that uses the open source Alpaca Forms package:

http://www.alpacajs.org/

I'm using Node version: v0.10.25

When I run the test page from the tutorial:

http://www.alpacajs.org/tutorial.html

Using the second sample page found in that tutorial:

<html>
    <head>
        <link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
        <link type="text/css" href="//code.cloudcms.com/alpaca/1.5.17/bootstrap/alpaca.min.css" rel="stylesheet" />
        <script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.3/handlebars.js"></script>
        <script type="text/javascript" src="//code.cloudcms.com/alpaca/1.5.17/bootstrap/alpaca.min.js"></script>
    </head>
    <body>
        <div id="form"></div>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#form").alpaca({
                    "schema": {
                        "title":"User Feedback",
                        "description":"What do you think about Alpaca?",
                        "type":"object",
                        "properties": {
                            "name": {
                                "type":"string",
                                "title":"Name"
                            },
                            "feedback": {
                                "type":"string",
                                "title":"Feedback"
                            },
                            "ranking": {
                                "type":"string",
                                "title":"Ranking",
                                "enum":['excellent','ok','so so']
                            }
                        }
                    }
                });
            });
        </script>
    </body>
</html>

I get the following two errors in the Chrome Debugger console, complaining that the templates I am using were compiled with a newer version of Handlebars than the current run-time, not older like most of the reported problems on SO specify. Here is the error dump from the Chrome Debugger console:

Uncaught Error: Template was precompiled with a newer version of Handlebars than the current runtime. 
Please update your runtime to a newer version (>= 4.0.0).
    Exception @ handlebars.js:2520
    checkRevision @ handlebars.js:2693
    template @ handlebars.js:2709
    hb.template @ handlebars.js:196
    (anonymous function) @ alpaca.min.js:1
    (anonymous function) @ alpaca.min.js:1
    (anonymous function) @ alpaca.min.js:1

Uncaught TypeError: $(...).alpaca is not a function
    (anonymous function) @ (index):14
    j @ jquery-1.11.1.min.js:2
    k.fireWith @ jquery-1.11.1.min.js:2
    m.extend.ready @ jquery-1.11.1.min.js:2
    J @ jquery-1.11.1.min.js:2

I checked with NPM and I am using a version of Handlebars that is newer than 4.0.0:

$ npm ls | grep handlebars
└─┬ handlebars@4.0.5

So it appears the error message is wrong?

I found these two related SO posts:

Template was precompiled with an older version of Handlebars than the current runtime

Uncaught Error: Template was precompiled with an older version of Handlebars

But I am not using Gulp or Ember.JS so I don't know if the remedies given apply to my situation.

Here is a list of the packages I have installed according to NPM:

npm ls
/home/roschler
├─┬ express@4.13.4
│ ├─┬ accepts@1.2.13
│ │ ├─┬ mime-types@2.1.10
│ │ │ └── mime-db@1.22.0
│ │ └── negotiator@0.5.3
│ ├── array-flatten@1.1.1
│ ├── content-disposition@0.5.1
│ ├── content-type@1.0.1
│ ├── cookie@0.1.5
│ ├── cookie-signature@1.0.6
│ ├─┬ debug@2.2.0
│ │ └── ms@0.7.1
│ ├── depd@1.1.0
│ ├── escape-html@1.0.3
│ ├── etag@1.7.0
│ ├─┬ finalhandler@0.4.1
│ │ └── unpipe@1.0.0
│ ├── fresh@0.3.0
│ ├── merge-descriptors@1.0.1
│ ├── methods@1.1.2
│ ├─┬ on-finished@2.3.0
│ │ └── ee-first@1.1.1
│ ├── parseurl@1.3.1
│ ├── path-to-regexp@0.1.7
│ ├─┬ proxy-addr@1.0.10
│ │ ├── forwarded@0.1.0
│ │ └── ipaddr.js@1.0.5
│ ├── qs@4.0.0
│ ├── range-parser@1.0.3
│ ├─┬ send@0.13.1
│ │ ├── destroy@1.0.4
│ │ ├─┬ http-errors@1.3.1
│ │ │ └── inherits@2.0.1
│ │ ├── mime@1.3.4
│ │ ├── ms@0.7.1
│ │ └── statuses@1.2.1
│ ├── serve-static@1.10.2
│ ├─┬ type-is@1.6.12
│ │ ├── media-typer@0.3.0
│ │ └─┬ mime-types@2.1.10
│ │   └── mime-db@1.22.0
│ ├── utils-merge@1.0.0
│ └── vary@1.0.1
└─┬ handlebars@4.0.5
  ├── async@1.5.2
  ├─┬ optimist@0.6.1
  │ ├── minimist@0.0.10
  │ └── wordwrap@0.0.3
  ├─┬ source-map@0.4.4
  │ └── amdefine@1.0.0
  └─┬ uglify-js@2.6.2
    ├── async@0.2.10
    ├── source-map@0.5.3
    ├── uglify-to-browserify@1.0.2
    └─┬ yargs@3.10.0
      ├── camelcase@1.2.1
      ├─┬ cliui@2.1.0
      │ ├─┬ center-align@0.1.3
      │ │ ├─┬ align-text@0.1.4
      │ │ │ ├─┬ kind-of@3.0.2
      │ │ │ │ └── is-buffer@1.1.3
      │ │ │ ├── longest@1.0.1
      │ │ │ └── repeat-string@1.5.4
      │ │ └── lazy-cache@1.0.3
      │ ├─┬ right-align@0.1.3
      │ │ └─┬ align-text@0.1.4
      │ │   ├─┬ kind-of@3.0.2
      │ │   │ └── is-buffer@1.1.3
      │ │   ├── longest@1.0.1
      │ │   └── repeat-string@1.5.4
      │ └── wordwrap@0.0.2
      ├── decamelize@1.2.0
      └── window-size@0.1.0

How can I fix these errors?

Community
  • 1
  • 1
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227

1 Answers1

5

In the example HTML, the Handlebars library being included via a script tag needs to be updated. When it refers to the runtime one, you need to update the JS library you are explictly including and not the NPM package (usually).

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.3/handlebars.js"></script>

Should actually include one with version 4.0.0+. For example

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.0/handlebars.js"></script>
Shakespeare
  • 1,286
  • 9
  • 15
  • Thank! That did it. It works now. By the way, during the (re)-install of handlebars 4.0.5 using NPM I got the following warnings. Should I worry about them? [ WARNING 1] npm http 304 https://registry.npmjs.org/is-buffer npm WARN engine is-buffer@1.1.3: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"})[ WARNING 2] npm http 304 https://registry.npmjs.org/lazy-cache npm WARN engine is-buffer@1.1.3: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"}) – Robert Oschler Apr 03 '16 at 21:42
  • 1
    No problem. And generally these collisions don't cause problems in my experience. You should be fine with ignoring them (so long as all works well with them of course). If you find an unusual issue with the building of handlebars, then maybe researching them would be a starting point. But I never tend to worry about these types of clashes - get them all the time. I tend to use node version >=0.12 though, as it seems to clean up things like this. – Shakespeare Apr 04 '16 at 07:30