我目前正尝试在Openshift上部署应用程序。由于openshift使用旧版本的npm(不支持版本号中的^),我创建了一个shrinkwrap.json文件。
通过在服务器上运行npm install我得到:
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-contrib-clean@0.5.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-coffee@0.10.1 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-concat@0.3.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-copy@0.5.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-cssmin@0.9.0 wants grunt@~0.4.1
npm ERR! peerinvalid Peer grunt-contrib-jst@0.6.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-less@0.10.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-uglify@0.4.0 wants grunt@^0.4.0
npm ERR! peerinvalid Peer grunt-contrib-watch@0.5.3 wants grunt@~0.4.0
在我的package.json中,我有:
"dependencies": {
....
"grunt": "~0.4.5",
....
我无法改变例如grunt-contrib-cssmin因为它们是我依赖项中的另一个包的依赖项。
任何人都有想法让它运行起来吗?
提示:Openshift运行npm v.1.2.4
答案 0 :(得分:1)
我建议(如果您无法更改^
文件中的package.json
标志)是提交来源控制您的依赖项并尝试禁用npm install
运行通过OpenShift。检查您部署的事物中的依赖关系的想法实际上变得越来越普遍,并且避免了您遇到的任何这些部署问题。这里有几篇文章表达了我的观点:
http://www.futurealoof.com/posts/nodemodules-in-git.html
https://www.npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
但我认为您无法禁用npm install
,这意味着您可以尝试以下操作:
我不是最熟悉的OpenShift,但可能至少能指出你正确的方向。据我了解OpenShift,有action_hooks
允许您覆盖(或至少参与)构建和部署步骤。这里有一些例子,这是我发现的一个例子:https://github.com/ramr/nodejs-custom-version-openshift/blob/master/.openshift/action_hooks/build
如果无法代表您禁用 npm install
运行,那么也许您可以通过提供之前更换的假package.json
来破解它到构建步骤,这将导致npm install
成为无操作。不是最好的,但它至少可以让你前进。