I am trying to run my node application on a new server, and I have some problems with the NODE_PATH environment variable. The application works fine on my local machine (OSX Lion), but not on the server (Redhat linux). When I launch my application with node app.js from my project directory /development/nodeproject , I get the following error:
Error: Cannot find module 'mod/core/models/Category' at Function._resolveFilename (module.js:334:11) at Function._load (module.js:279:25) at Module.require (module.js:357:17) at require (module.js:368:17) at /development/nodeproject/app.js:57:5 at Object.<anonymous> (/development/nodeproject/app.js:258:1) at Module._compile (module.js:432:26) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12)
mod/core/models/Category is the first require () in my app.js application and looks like this: var Category = require('mod/core/models/Category') . Thus, it is obvious that node is not looking for modules in my project directory.
I'm not sure why, though, because I made the following changes (which work fine on my local machine).
- added
export NODE_PATH=/development/nodeproject to my ~ / .bash_profile - ran
source ~/.bash_profile - If I run
env , I see NODE_PATH=/development/nodeproject specified there - in my app.js, if I have a console log
process.env.NODE_PATH I get /development/framework (should this output an array instead of a string?)
Other information that may be relevant:
- I am node v0.6.7
- I do it all as root (sudo su -)
At this point, I'm not sure what else I can do. Any help would be greatly appreciated.
source share