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
└─┬ selenium-webdriver@2.53.1
├── adm-zip@0.4.4
├─┬ rimraf@2.5.2
│ └─┬ glob@7.0.3
│ ├─┬ inflight@1.0.4
│ │ └── wrappy@1.0.1
│ ├── inherits@2.0.1
│ ├─┬ minimatch@3.0.0
│ │ └─┬ brace-expansion@1.1.3
│ │ ├── balanced-match@0.3.0
│ │ └── concat-map@0.0.1
│ ├── once@1.3.3
│ └── path-is-absolute@1.0.0
├── tmp@0.0.24
├─┬ ws@1.1.0
│ ├── options@0.0.6
│ └── ultron@1.0.2
└─┬ xml2js@0.4.4
├── sax@0.6.1
└── xmlbuilder@8.2.2
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?