I’m using Amazon Linux and node version 5.10.0. I want to install a module globally, so that I can run node scripts from different directories for different users. So I tried the below …
[davea@mydevbox ~]$ sudo npm install -g selenium-webdriver
/usr/lib
└─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]
I received no errors, and so assumed all was well. But then when I logged in as a different user, and tried to run a script, I get this error complaining about missing the module I just installed …
[davea@mydevbox ~]$ sudo su - jboss
Last login: Tue Apr 26 15:13:47 UTC 2016 on pts/0
[jboss@mydevbox ~]$ cd .jenkins/jobs/subco/workspace/
[jboss@mydevbox workspace]$ cd automated-tests/
[jboss@mydevbox automated-tests]$ cd nodejs/
[jboss@mydevbox nodejs]$ sh run_test.sh
(EE)
Fatal server error:
(EE) Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock
and start again.
(EE)
Validation Complete
module.js:341
throw err;
^
Error: Cannot find module 'selenium-webdriver'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/jboss/.jenkins/jobs/subco/workspace/automated-tests/nodejs/js/Optimus.js:2:17)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
How do I install a module globally so that it is visible to everyone?