linux - node.js cannot find module xml2js -


i made application on machine, , works well. uploaded server, , crashing following error:

node.js:116         throw e; // process.nexttick error, or 'error' event on first tick         ^ error: cannot find module 'xml2js'     @ function._resolvefilename (module.js:289:11)     @ function._load (module.js:241:25)     @ require (module.js:317:19)     @ object.<anonymous> (/var/www/node/price/index.js:3:14)     @ module._compile (module.js:373:26)     @ object..js (module.js:379:10)     @ module.load (module.js:305:31)     @ function._load (module.js:271:10)     @ array.<anonymous> (module.js:392:10)     @ eventemitter._tickcallback (node.js:108:26) 

this how app starts:

var express=require('express'); var http=require('http'); var xml2js = require('xml2js'); var sys = require('sys'); var util = require('util'); 

i have installed both express , xml2js using npm. have exact same version (v0.4.0) node on machine , server.

i have made sure path wher xml2js , express reside (/usr/local/lib/node/) included in paths node looks modules. (i edited file 'module.js' print paths looking modules.)

node.js:116         throw e; // process.nexttick error, or 'error' event on first tick         ^ error: cannot find module 'xml2js', in paths: /root/.node_modules,/root/.node_libraries,/usr/local/lib/node,/var/www/node/price/node_modules,/var/www/node/node_modules,/var/www/node_modules,/var/node_modules,/node_modules     @ function._resolvefilename (module.js:289:11)     @ function._load (module.js:241:25)     @ require (module.js:317:19)     @ object.<anonymous> (/var/www/node/price/index.js:3:14)     @ module._compile (module.js:373:26)     @ object..js (module.js:379:10)     @ module.load (module.js:305:31)     @ function._load (module.js:271:10)     @ array.<anonymous> (module.js:392:10)     @ eventemitter._tickcallback (node.js:108:26) 

so wrong? have right path, module there. why can't node find it? , exact same code runs smoothly on local machine. if matters, machine mac, , server runs centos.

require.paths.push('/usr/local/lib/node_modules'); 

is no longer valid node v0.8.1 , above. instead of using require.paths.push, can set environment variable node_path

export node_path=/usr/local/lib/node_modules 

or if install npm modules in home directory, then

export node_path=~/.npm 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -