I am very new to node.js and i am follwing a few different tutorials. My goal is to use node with ejs or underscore. My first attempt with using underscore isn't going really well.
I am using bower to manage script dependencies for my project and i was able to pull down the the amd version of underscore under the path public/javascripts/vendor. I am confident that if i were to install underscore using npm, the module would be found and the error would go away.
I thought setting the app.config with this line
app.use(express.static(path.join(__dirname, 'public')));
essentially uses all static files under that directory? How come then, underscore can't be found..
This i how i am using it by the way.
var _ = require('underscore-amd');
app.register('.html', {
compile: function(str, options){
var compiled = require('underscore-amd').template(str);
return function(locals) {
return compiled(locals);
};
}
});
You mention npm, so that is the correct way to use underscore in node:
{
"name": "example",
"version": "0.0.1",
"dependencies": {
"underscore": "*",
}
}
Bower is for client-side, and you can't (easily) use a bower lib in node.
This is for serving static files to client:
app.use(express.static(path.join(__dirname, 'public')));
not for use by node on the server-side.