Description of problem: I need to call NODE_PATH=/usr/lib/node_modules node file.js otherwise (without NODE_PATH) node won't find the required modules.
This is by design. Node.js' global module search path is by default set only to './node_modules', to allow the developer to create separate directories with separate dependency chains, similar to how virtualenv works with Python. To use yum-installed dependencies, just `npm link` them into your local project. To use dependencies we don't have yet, just `npm install` them. For instance: % mkdir test % cd test % cat >test.js <<EOF > var request = require('request') > request('https://badges.fedoraproject.org/user/fabiand/json', function (error, response, body) { > if (!error && response.statusCode == 200) { > var num = JSON.parse(body).assertions.length > console.log('You have ' + num + ' badges!') > } > }) > EOF % node test.js Error: Cannot find module 'request' % npm link request % node test.js You have 20 badges! For more information on the rationale behind this, see the npm FAQ: https://npmjs.org/doc/faq.html#I-installed-something-globally-but-I-can-t-require-it
Thanks for this explanation.