require-handlebars-plugin
require-handlebars-plugin copied to clipboard
Can not Compile hbs.js using requirejs-rails
I have rails app using backbone , handlebars and requirejs-rails. Everything is working perfectly in development mode, no compiled assets. When I try to compile I am getting this error:
Compiled lib/hbs.js (0ms) (pid 46635)
/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:14166
throw new Error(errorMsg);
^
Error: TypeError: string is not a function
In module tree:
application
app/setup
app/router
views/app_view
views/shared/main_header
views/shared/company_brand_campaign_header
hbs
at recursiveNodeSearch (eval at <anonymous> (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:13718:38), <anonymous>:146:17)
at build (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:14166:23)
at runBuild (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:15358:30)
at Object.context.execCb (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:1773:33)
at Object.Module.check (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:1083:51)
at Object.Module.enable (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:1324:22)
at Object.Module.init (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:982:26)
at Object.context.require (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:1579:28)
at requirejs (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:1857:24)
at Function.requirejs.optimize (/Users/velles/.rvm/gems/ruby-1.9.3-p286/gems/requirejs-rails-0.9.0/bin/r.js:15368:13)
at /Users/velles/development/hyfn_projects/hyfn8r/tmp/rjs_driver.js:130:15
rake aborted!
My require.js configuration is
(function() {
requirejs.config({
"baseUrl": "/assets/lib",
paths: {
app: "../app",
assets: "../",
classes: "../app/classes",
collections: "../app/collections",
helpers: "../app/helpers",
mixins: "../app/mixins",
models: "../app/models",
views: "../app/views",
templates: "../app/templates"
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone-validation': {
deps: ['backbone'],
exports: 'Backbone'
},
'underscore': {
exports: '_'
},
'deep-model': {
deps: ['underscore', 'jquery'],
exports: 'DeepModel'
},
'assets/plugins': {
deps: ['underscore', 'jquery'],
exports: 'jquery'
},
'assets/highcharts': {
exports: 'Highcharts'
},
'assets/date.format': {
exports: 'dateFormat'
},
'assets/google_charts': {
deps: ['https://www.google.com/jsapi'],
exports: 'GoogleCharts'
},
'assets/jquery.ajaxfileuploader': {
deps: ['jquery'],
exports: '$'
},
'assets/lib/jquery.number.min': {
deps: ['jquery'],
exports: '$'
},
'jquery-ui': {
deps: ['jquery'],
exports: '$'
},
'assets/jquery-tokeninput/jquery.tokeninput': {
deps: ['jquery'],
exports: '$'
},
'assets/jquery.ptTimeSelect': {
deps: ['jquery'],
exports: '$'
},
'assets/jquery.ajaxfileuploader': {
deps: ['jquery'],
exports: '$'
},
'': ''
},
hbs: {
disableI18n: true,
helperPathCallback: function(name) {
return 'templates/helpers/' + name;
}
}
});
requirejs(["app/setup"]);
}).call(this);
Any help will be appreciated , thanks.
Same here.
I keep getting this error:
Error: TypeError: Cannot call method 'push' of undefined
In module tree:
lantern/visage/app
shared/views/header
at /srv/ganesh/.gem/bundler/gems/requirejs-rails-f2330104aeca/bin/r.js:21426:38
rake aborted!
Asset compilation with node failed.
I am also getting an error but its not one that I have seen on any sort of thread out there. This maybe because I am missing something super obvious, but its a real pain.
My app works just fine in development, but when trying to precompile assets (this is a rails app btw) or push it to heroku I am getting an error.
When pushing to heroku I am getting the following error.
Asset compilation with node failed with error:
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'Error: EBADF, Bad file descriptor \'/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/tmp/requirejs/dst/hbs.js\'\nIn module tree:\n application\n app\n utils/router\n routes\n views/dashboard\n\n at Object.openSync (fs.js:221:18)\n',
originalError:
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'EBADF, Bad file descriptor \'/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/tmp/requirejs/dst/hbs.js\'',
errno: 9,
code: 'EBADF',
path: '/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/tmp/requirejs/dst/hbs.js',
fileName: '/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/tmp/requirejs/dst/hbs.js',
moduleTree:
[ 'views/dashboard',
'routes',
'utils/router',
'app',
'application' ] } }
/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/vendor/bundle/ruby/2.1.0/gems/requirejs-rails-0.9.4/lib/tasks/requirejs-rails_tasks.rake:139:in `block (3 levels) in <top (required)>'
Tasks: TOP => requirejs:precompile:all => requirejs:precompile:run_rjs
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d954...]
/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/vendor/bundle/ruby/2.1.0/gems/requirejs-rails-0.9.4/lib/tasks/requirejs-rails_tasks.rake:19:in `ruby_rake_task'
/tmp/build_6f6dc0e8-95be-4d9f-8219-a64d95412b34/vendor/bundle/ruby/2.1.0/gems/requirejs-rails-0.9.4/lib/tasks/requirejs-rails_tasks.rake:86:in `block (3 levels) in <top (required)>'
Tasks: TOP => assets:precompile => requirejs:precompile:external
(See full trace by running task with --trace)
The following is my application.js
require.config({
shim : {
handlebars: {
exports: 'Handlebars'
}
},
paths: {
hasher: 'hasher',
crossroads: 'crossroads',
signals: 'signals',
handlebars: 'handlebars',
hbs: 'require-handlebars-plugin/hbs',
templates: 'templates'
},
hbs: {
disableI18n: true,
templateExtension: 'hbs'
}
});
require(['jquery', 'app'], function($, App){
App.initialize()
});
I am pretty lost as far as what this error could be so any help would be awesome.