I'm using :
I'm trying to create a simple Mojito application using NodeJS modules, packaged with NPM.
Documentation say that :
Indeed, the example above isn't working.
"dependencies": {
"mojito": "0.5.x",
"async": "0.2.x"
},
status: function(ac) {
var async = require('async');
ac.done({
status: 'loaded'
});
}
Mojito server : "Error: Cannot find module 'async'"
Web page error : "Error: MODULE_NOT_FOUND"
Any clue ?
PS : Of course, after npm install, the project folder have a node_modules folder with the async package.
As today, mojito
npm package is used as a cli but it also holds the mojito core. This is problematic because most developers will run the app by doing mojito start
, which runs from the global mojito
package. This, plus the fact that the current YUI is messing with the require
, it causes a lot of troubles when requiring dependencies.
The solution is simple, make sure you install mojito locally in your application, and run the app by doing ./node_modules/mojito/bin/mojito start
or by doing node server.js
instead of mojito start
.
Aside from that, we are working on splitting the cli and core into separate packages, and waiting for YUI 3.9.0
to solve this problem once for all so developers can keep using mojito start
.