1

I am trying to deploy a Sails.js app to Bluemix and we are getting the following error during the deploy stage in the toolchain on Bluemix (When the CF PUSH command is called):

npm ERR! Cannot read property 'pause' of undefined

I understand the trace goes to the npm-error.log file, however, I haven't been able to get to it as we cannot ssh in to see whats in the file as the application is in its "off" state after a bad deploy.

This same code was successfully deployed with both Cf push {app name}} and through a simple build and deploy toolchain in Bluemix just 8 days ago.

In the build stage I can run Npm install and npm update just fine. However, it seems to do this again in the deploy stage regardless and it fails. Here is some detail on this failure

NODE_ENV=production
   NPM_CONFIG_LOGLEVEL=error
   NPM_CONFIG_PRODUCTION=true
   Visit http://docs.cloudfoundry.org/buildpacks/node/index.html#vendoring
   NODE_HOME=/tmp/app/.cloudfoundry/0/node
   NODE_MODULES_CACHE=true
   NODE_VERBOSE=false
Restoring cache
       Loading 3 from cacheDirectories (default):
       - .npm
       - .cache/yarn (not cached - skipping)
       - bower_components (not cached - skipping)
       Installing node modules (package.json) Building dependencies
 sails@0.12.13 preinstall /tmp/app/node_modules/sails
 node ./lib/preinstall_npmcheck.js
Sails.js Installation: Checking npm-version successful
npm ERR! Cannot read property 'pause' of undefined
npm ERR!     /tmp/app/.npm/_logs/2017-09-09T17_02_48_660Z-debug.log
       **ERROR** Unable to build dependencies: exit status 1
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
Destroying container
npm ERR! A complete log of this run can be found in:
Successfully destroyed container

Package.json file

{
  "name": "myApp",
  "private": true,
  "version": "0.0.1",
  "description": "Stuff my app does",
  "keywords": [
    "Cool Apps"
  ],
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cacheman": "^2.2.1",
    "ejs": "2.3.4",
    "elasticsearch": "^13.0.0-rc2",
    "find-remove": "^1.0.1",
    "fs": "0.0.1-security",
    "grunt": "1.0.1",
    "grunt-contrib-clean": "1.0.0",
    "grunt-contrib-coffee": "1.0.0",
    "grunt-contrib-concat": "1.0.1",
    "grunt-contrib-copy": "1.0.0",
    "grunt-contrib-cssmin": "1.0.1",
    "grunt-contrib-jst": "1.0.0",
    "grunt-contrib-less": "1.3.0",
    "grunt-contrib-uglify": "1.0.1",
    "grunt-contrib-watch": "1.0.0",
    "grunt-sails-linker": "~0.10.1",
    "grunt-sync": "0.5.2",
    "include-all": "^1.0.0",
    "jsonwebtoken": "^7.3.0",
    "moment": "^2.18.1",
    "moment-timezone": "^0.5.13",
    "passport": "^0.2.x",
    "passport-http-bearer": "^1.0.1",
    "passport-idaas-openidconnect": "^1.1.0",
    "passport-local": "^1.0.0",
    "rc": "1.0.1",
    "request": "^2.81.0",
    "request-promise": "^4.2.0",
    "sails": "~0.12.13",
    "sails-disk": "~0.10.9",
    "sails-mongo": "^0.12.2",
    "stream": "0.0.2",
    "uuid-1345": "^0.99.6",
    "validator": "^7.0.0",
    "natural-sort": "^1.0.0"
  },
  "scripts": {
    "start": "node app.js"
  },
  "engines": {
    "node": "^8.0.x",
    "npm": "^5.0.x"
  },
  "main": "app.js",
  "author": "Scott N",
  "license": ""
}

Things I've tried so far. -change node versions -changed npm versions -change dependencies versions to include the ^ prefix -removed all dependencies but Sails in the package.json file

So Sails.js and the Nodebuildpack/Bluemix aren't playing well with each other.

Any help would be appreciated. Thank you

ScottN
  • 11
  • 1
  • 2

3 Answers3

3

It happens to me just the same. and I've to roll back the prev version of npm: 5.3.0 and it's working now. (BTW: macOS)

The error only happens when I update my npm version like this:

  Update available 5.3.0 → 5.4.1    
   Run npm i -g npm to update      
M.T.
  • 31
  • 2
  • it actually runs fine on my Mac. Even when i cycled through all the old NPM versions and node version in ran fine. The problem is when it runs on Bluemix it errors out like this. I will give this a shot and see what happens. – ScottN Sep 11 '17 at 02:50
  • I tried that in the deploy and build phase and this didn't work. What I ended up doing is having Sails.js version 12.2, Node version 8.2.1 and NPM 5.3.0 and this worked. I appreciate the answer – ScottN Sep 12 '17 at 16:10
1

The best way to handle it is to update your package.json to use engines like so

"description": "a Sails application",
  "keywords": [],
  "engines": {
    "node": "6.10.1",
    "npm": "5.3.0"
  },

Got this issue while trying to push to heroku which seems to be the npm version specified by @m-t, and also specifying the versions like above makes ibm bluemix pick it up as default node engine instead of using the latest stable version.

And don't forget to always specify your node and npm versions directly, instead of adding tilde or caret, this just to be safe. check https://stackoverflow.com/a/22345808/5836034 for more about tilde and caret

you can still check @sai-vennam answer here for more info

Theophilus Omoregbee
  • 2,463
  • 1
  • 22
  • 33
0

So I rolled back the sails version in the package.json file from 0.12 to 0.11 and it deployed fine. So CF PUSH and the newest sails version are not getting along on Bluemix. This was using Node 8.0 and NPM version ^5.0.x

ScottN
  • 11
  • 1
  • 2
  • am using sails v 0.12.13 and it's working well by updating the `engine` on the `package.json` – Theophilus Omoregbee Sep 12 '17 at 05:42
  • Where is it working well? Bluemix ? This is where the issue is not locally. I can literally run this project everywhere but Bluemix. As described in the question, the package.json file has engines specified this is how i cycled through all the node and npm versions. – ScottN Sep 12 '17 at 14:46
  • it works locally on cloud build it fails, because you are specifing your engine to use the latest major release https://stackoverflow.com/a/22345808/5836034 – Theophilus Omoregbee Sep 12 '17 at 14:50