5

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"
},

I also have a custom .npmrc that points scope @shawnzhu to my private npm registry.

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.

After reviewing the whole console output I realized it uses npm v1.4.28 which doesn't support scoped packages.

How can I get npm v2.0.0+ in a node.js app in bluemix?

Nick Bartlett
  • 4,865
  • 2
  • 24
  • 37
shawnzhu
  • 7,233
  • 4
  • 35
  • 51

3 Answers3

8

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

You've specified the npm version in your package.json correctly, so it should work for the community buildpack.

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/

This buildpack comes with the ability to specify NPM versions by including an "npm" entry in your package.json, like so:

"engines": {
    "npm": "xxxxxxx"
},
Community
  • 1
  • 1
Sai Vennam
  • 537
  • 2
  • 8
2

I was also able to get this working using Node 0.12.2, with the following changes:

In package.json:

  "engines": {
    "npm": ">2.0.0",
    "node": ">=0.12.0"
  },
1

As of the latest Bluemix node.js default buildpack (c.Jun 4, 2015), you can specify a version of npm >2.0.0, which installs a version of npm >2.7, which is the requirement to support and import scoped npm packages. I have tested this for a publicly scoped package and it is up and running in production in Bluemix, using the default node.js buildpack.

If you don't want to revert and use the cf community buildpack, you can use the "engines.npm" property and that should get you up and running, even in node 0.10.x.

In package.json, specify:

 "engines": {
    "npm": ">2.0.0",
    "node": "0.10.x"
  }

I've edited this answer for clarity. Many thanks to @shawnzhu for comments. Hope this helps.

novaedge
  • 11
  • 3
  • this feature belongs to Bluemix default node.js buildpack, I want to know which change in default nodejs buildpack brings this feature instead of saying "it works now" only. – shawnzhu Jun 05 '15 at 02:05
  • @shawnzhu, I've updated my answer for clarity. What it looks like is that the features of the Bluemix node.js default buildpack now support specifying "engines.npm" >2.0 and scoped npm packages can now be utilized. I'm not sure what they changed, but I added my answer here, b/c the answer from sai-vennam above seems already to be out of date. – novaedge Jun 08 '15 at 23:23
  • it doesn't work today and @Sai Vennam mentioned that the current production Node.js buildpack version on bluemix is v1.18-20150519-1759, which does not support this feature yet. re-accept his answer. and I will keep eyes on this – shawnzhu Jun 10 '15 at 17:50