1

I am trying to use passportjs with Mojito by doing the following:

1) after installing Node JS and Mojito

2) created a Mojito app

3) created a Mojito

4) included passport as a dependency in the package.json of the Mojito app

5) ran npm install (it fetched passport into the node_modules directory, which is in the app dir)

6) in the function for the init action of the controller (in controller.server.js of the mojit created in step 3), I am requiring the passport module (this.passport = require('passport')), however Mojito complains with the following error:

/usr/local/lib/node_modules/mojito/node_modules/yui/yui-nodejs/yui-nodejs.js:1147
            throw (e || new Error(msg));
                        ^
Error: Cannot find module 'passport'

I've tried adding passport to the requires array that is passed to the YUI.add function in controller.server.js and according to the logs the mojito dispatcher is dispatching an instance of the my mojit/index with the passport module, however it also warns: [YUI-WARN] yui: NOT loaded: passport

Any ideas of what I might be doing wrong or any example of using any non-YUI nodejs module in Mojito?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • This has been solved at: http://developer.yahoo.com/forum/Yahoo-Mojito/Using-Passport-JS-with-Mojito/1347478967128-30d8251c-4103-49dc-b555-bec39e9ebe1d Solution: append the NODE_PATH environment variable with: ./node_modules:/opt/local/lib/node:/opt/local/lib/node_modules – user1666771 Sep 16 '12 at 00:27

2 Answers2

0

This has been solved at: http://developer.yahoo.com/forum/Yahoo-Mojito/Using-Passport-JS-with-Mojito/1347478967128-30d8251c-4103-49dc-b555-bec39e9ebe1d

Solution: append the NODE_PATH environment variable with: ./node_modules:/opt/local/lib/node:/opt/local/lib/node_modules

0

Two things:

  • passport is not a YUI module, so you can't add it to the requires array in your controller. Instead, you need to require it as a regular node module using require('passport)`

  • there is a known issue in mojito/yui (which is going to be solved with YUI 3.9.0), where local node modules will not be recognized thru require() if you're using mojito start, which is running globally from the mojito cli. The solution is to not rely on the global cli to boot your application, and instead use ./node_modules/mojito/bin/mojito start from the app folder.

caridy
  • 244
  • 2
  • 5