尝试使用restify和mongojs模块设置一个托管在openshift上的简单 Node 应用程序。我对应用程序所做的唯一更改是添加
"restify": "latest",
"mongojs": "latest"
到 package.json 中的依赖项部分,然后进行 git Push。
由于我也想设置本地开发/测试环境,因此正在使用 http://openshift.github.io/documentation/oo_cartridge_guide.html#local-development-testing 提供的文档
如文档中所述 - 如果我运行
ssh <uid>@<appname>.rhcloud.com npm list -g
我收到一长串以
结尾的错误npm WARN unmet dependency /opt/rh/nodejs010/root/usr/lib/node_modules/ws requires options@'latest' but will load
npm WARN unmet dependency /opt/rh/nodejs010/root/usr/lib/node_modules/options,
npm WARN unmet dependency which is version 0.0.5
npm ERR! missing: npm@*, required by undefined@undefined
npm ERR! missing: openshift-node-web-proxy@*, required by undefined@undefined
npm ERR! invalid: options@0.0.5 /opt/rh/nodejs010/root/usr/lib/node_modules/options
npm ERR! not ok code 0
错误正文包含很多错误,例如...
glob error { [Error: EACCES, readdir '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man/man3/whoami.3']
errno: 3,
code: 'EACCES',
path: '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man/man3/whoami.3' }
glob error { [Error: EACCES, readdir '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man/man3/whoami.3']
errno: 3,
code: 'EACCES',
path: '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man/man3/whoami.3' }
建议的行动方案是什么? 如何修复这些错误? 应用程序是否处于损坏状态?
最佳答案
在 Openshift 上,您不能不应全局安装内容。
使用本地模块,如果您需要运行可执行文件(如咖啡、摩卡、grunt...),请从 node_modules\.bin
文件夹启动它们。
--- 编辑 ---
正如 official documentation 中所述,可以全局安装东西,但不推荐。我想你应该有足够的权利。
the better alternative though is to install them in the home directory of the currently logged user on your local machine/workstation.
如果您确实需要全局的东西,请考虑将它们放入您的购物车中:在不同的虚拟机上进行扩展时会更方便
关于node.js - 尝试获取 openshift/nodejs 上已安装模块的列表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140675/