I'm trying to install globally and then use forever and forever-monitor like this:
npm install -g forever forever-monitor
I see the usual output and also the operations that copy the files to the global path, but then if I try to require("forever"); I get an error saying that the module wasn't found.
I'm using latest version of both node and npm and I already know about the change that npm made in global vs local install, but I really don't want to install localy on every project and I'm working on a platform that doesn't support link so npm link after a global install isn't possible for me.
My question is: why I can't require a globally installed package? Is that a feature or a bug? Or am I doing something wrong?
PS: Just to make it crystal clear: I don't want to install locally.
In Node.js, require doesn't look in the folder where global modules are installed.
You can fix this by setting the NODE_PATH environment variable. In Linux this will be:
export NODE_PATH=/usr/lib/node_modules (this depend on where your global modules are actually installed).
See here: http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
After you install package globally you have to link the local project with global package
npm install express -g
cd ~/mynodeproject/
npm link express
See here
Apologies for the necromancy but I'm able to specify hard-links to globally installed modules:
var pg = require("/usr/local/lib/node_modules/pg");
This isn't perfect but considering that Unity3d tries to "compile" all javascript that is included in the project directory I really can't install any packages.