将Node.js应用程序部署到Bluemix时如何指定npm版本?
我在package.json
中创建了一个运行时依赖项为作用域软件包的node.js应用程序. :
I created a node.js application with runtime dependencies of scoped packages in my package.json
:
"dependencies": {
"@shawnzhu/mybot" : "latest",
...
},
"engines": {
"npm": ">2.0.0",
"node": "0.10.38"
},
我还有一个自定义.npmrc
,它将范围@shawnzhu
指向我的私有npm注册表.
I also have a custom .npmrc
that points scope @shawnzhu
to my private npm registry.
当前,它在部署到heroku(将npm升级到v2.7.x)时有效.但是,cf push
到bluemix失败,控制台输出显示:
Currently it works when deploying to heroku, where it upgrades npm to v2.7.x. However, a cf push
to bluemix fails with the console output showing:
registry "@shawnzhu/mybot" not found.
查看了整个控制台的输出后,我意识到它使用的是npm
v1.4.28,该版本不支持作用域软件包.
After reviewing the whole console output I realized it uses npm
v1.4.28 which doesn't support scoped packages.
如何在bluemix中的node.js应用程序中获取npm v2.0.0 +?
How can I get npm v2.0.0+ in a node.js app in bluemix?
在2015年6月15日之前:到目前为止,无法在Bluemix上使用默认的Node.js buildpack.现在,您可以使用社区开源Node.js buildpack:
Before June 15, 2015: This was not possible using the default Node.js buildpack on Bluemix, yet. For now, you can use the community open-source Node.js buildpack:
cf push mynodeapp -b https://github.com/cloudfoundry/nodejs-buildpack
cf push mynodeapp -b https://github.com/cloudfoundry/nodejs-buildpack
您已经在package.json中正确指定了npm版本,因此它应该适用于社区buildpack.
You've specified the npm version in your package.json correctly, so it should work for the community buildpack.
2015年6月15日之后:Bluemix现已提供IBM Node.js Buildpack的最新版本!您可以在 https:上看到完整的更改: //developer.ibm.com/bluemix/2015/06/15/bluemix-node-js-buildpack-update/
After June 15, 2015: The newest version of the IBM Node.js Buildpack is now available on Bluemix! You can see the full changes at https://developer.ibm.com/bluemix/2015/06/15/bluemix-node-js-buildpack-update/
此buildpack具有通过包含"npm"和"npm"来指定NPM版本的能力.在package.json中的条目,如下所示:
This buildpack comes with the ability to specify NPM versions by including an "npm" entry in your package.json, like so:
"engines": {
"npm": "xxxxxxx"
},