我正在使用Amazon Linux和节点版本5.10.0。我想全局安装一个模块,这样我就可以为不同的用户从不同的目录运行节点脚本。所以我尝试了以下......
[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
我没有收到任何错误,所以假设一切都很顺利。但是当我以不同的用户身份登录并尝试运行脚本时,我收到此错误抱怨错过了我刚刚安装的模块...
[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)
如何全局安装模块以便每个人都可以看到它?