I am trying to deploy a node app that runs fine on my local Mac Lion, however. On the virtual Ubuntu box, it is giving an error:
module.js:340 throw err; ^ Error: Cannot find module '../lib/review' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/websites/Node_apps/min-driver-node/routes/reviews.js:2:14) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)
There is my own custom modules in ./lib folder that are 'require' from the routes as following:
var Review = require('../lib/review');
What have I tried?
- Ensured the same Node.js version running via nvm(https://github.com/creationix/nvm)
- Removed node_modules just to re-install them by running "npm install"
Why is the 'require' unable import the custom modules from 'lib' folder on Server while works on Mac? Thank You
It looks like the 'require' module is case sensitive on Ubuntu but not on Mac....all my modules in lib folder starts with upper case(i.e. lib/Review.js), but when required in other parts of the code, it is lower case - require('../lib/review'). This is causing issue on Ubuntu but not on Mac lion. By updating the code to 'require('../lib/Review'), solves the problem
Is this a bug and i should be reporting this?
This recipe can be found in it's original form on Stack Over Flow.