I am desparating with brunch/node.js. I have a project with a few simple pages, using brunch, backbone.js, jade, and coffeescript.
app/assets/index.html has the following scripts included:
<script src="data/vendor.js" type="text/javascript"></script>
<script src="data/app.js" type="text/javascript"></script>
<script src="data/data.js" type="text/javascript"></script>
<script type="text/javascript">require('initialize');</script>
brunch-config.coffee:
exports.config =
files:
javascripts:
defaultExtension: 'coffee'
joinTo:
'data/app.js': /^app/
'data/vendor.js': /^vendor/
order:
before: [
'vendor/scripts/jquery-1.11.1.js',
'vendor/scripts/underscore.js',
'vendor/scripts/backbone-1.1.2-full.js',
]
stylesheets:
joinTo:
'data/app.css': /^app\/styles/
templates:
defaultExtension: 'jade',
joinTo:
'data/app.js': /^app\/templates/
All the coffee files are compiled correctly and merged into vendor.js and app.js, and I can find the (javascript'ed) initialize.coffee code with grep in app.js. app/initialize.coffee:
# The function called from index.html
$(document).ready ->
app = require('application')
app.initialize()
return
I modelled this after the spa-bookmarks tutorial. But When I launch the brunch server, my Js browser console always tells me:
TypeError: _ is undefined
Error: Cannot find module "./initialize" from "/"
The TypeError doesn't bother me by now. But I can't find out why the heck the initialize module is not called.
I must admit that I am very new to Js and node.js, and have not fully understood (better: have no clue of) the way Js modules are bundled together and called.
I tried many possible variations, but did not get more out of it than this error message. Please help.