0

Load NodeJS Module

Hi there. I'm new user of Mojito.

I'm trying to create a simple Mojito application using NodeJS modules, packaged with NPM.

I have read documentation, but maybe I have missed something..

Working

status: function(ac) {
            var fs = require('fs');
            ac.done({
                status: 'loaded'
            });
}

Not working

"dependencies": {
    "mojito": "0.5.x",
    "async": "0.2.x"
},

status: function(ac) {
            var async = require('async');
            ac.done({
                status: 'loaded'
            });
}

Do you have any clue ?

Take a look on 'Mojito and npm Packaging' : http://developer.yahoo.com/cocktails/mojito/docs/topics/mojito_npm.html

  • Create a Mojito application.
  • Add any needed dependencies to dependencies object in package.json.
  • Install dependencies with npm: {app_dir}$ npm install
  • When Mojito starts, your application will have access to the installed npm modules.

Regards, Armetiz.

by
2 Replies
  • Armetiz:

    package.json only declares your app dependencies -- it tells "npm" to install some stuff when you run "npm i". When you run "npm i", it installs your dependencies to node_modules. This is where Mojito finds them. Can you verify them this directory exists? And has async.js in it?

    1
  • Armetiz, please, do not use mojito start, instead use ./node_modules/mojito/bin/mojito start from the app folder, that should solve the issue. We are in the process of fixing this in 0.5.7 with the introduction of the new pkg mojito-cli, will update this post when that gets released.

    0

Recent Posts

in Yahoo! Mojito