Reputation: 5968
I'm trying desperately to tie in the mu2 module into Express in node.js. However, I can't seem to figure it out, and when trying to run the example using the mu2express module, I keep getting this error when trying to run:
module.js:340
throw err;
^
Error: Cannot find module 'mu2Express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/myapp.js:1:80)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Is this an error caused by something locally, or with the module itself? Right now, I'm using the node http module to work with mu2 exclusively, but I really want to use express is possible.
Can anyone out there help? Is there more information I should provide? I'm very new to node.js and I could use some direction if possible!
Upvotes: 2
Views: 8209
Reputation: 8800
Look into consolidate:
https://github.com/visionmedia/consolidate.js/
It is made by the man behind Express himself and has support for Hogan and Handlebars.
EDIT:
You can initialize Express with this for consolidate
var express = require('express');
var cons = require('consolidate');
var app = express();
app.engine('html', cons.hogan);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
Renders will now be served from /views with HTML extension and Mustache-flavor syntax.
app.get('/', function (req, res) {
res.render('index', {msg: 'Hello world!'}
});
And a basic template, again just mustache-flavor syntax
Hello {{msg}}
Upvotes: 5
Reputation: 31477
You're requiring the mu2Express
module from the myapp.js
file, so you need to install it first.
You'll need to create a package.json
file with at least the following content:
{
"name": "myProject",
"version": "0.0.1",
"dependencies": {
"mu2express": "~0.0.1"
}
}
And I'm not sure, that the examples are good for this project, you may need to require mu2express
instead of mu2Express
.
Upvotes: 0