Search code examples
node.jsibm-cloudcloud-foundrynodemon

IBM Cloud - Node.js app won't deploy - nodemon not found


My Node.js app no longer deploys saying nodemon: not found. It was working 3 days ago, and I did not change any code, so not sure what the issue is. Yes, nodemon is in my package.json.

   2018-02-11T09:56:36.77-0500 [CELL/0] OUT Creating container
   2018-02-11T09:56:38.02-0500 [CELL/0] OUT Successfully created container
   2018-02-11T09:56:46.06-0500 [CELL/0] OUT Starting health monitoring of container
   2018-02-11T09:56:46.97-0500 [APP/PROC/WEB/0] OUT > my-api@0.1.0 start /home/vcap/app
   2018-02-11T09:56:46.97-0500 [APP/PROC/WEB/0] OUT > nodemon ./src/server.js --exec babel-node -e js
   2018-02-11T09:56:46.98-0500 [APP/PROC/WEB/0] ERR sh: 1: nodemon: not found
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! Linux 4.4.0-109-generic
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! node v6.12.3
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! npm  v3.10.10
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! file sh
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! errno ENOENT
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! syscall spawn
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! my-api@0.1.0 start: `nodemon ./src/server.js --exec babel-node -e js`
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! spawn ENOENT
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR!
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! Failed at the my-api@0.1.0 start script 'nodemon ./src/server.js --exec babel-node -e js'.
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! Make sure you have the latest version of node.js and npm installed.
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! If you do, this is most likely a problem with the my-api package,
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! not with npm itself.
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! Tell the author that this fails on your system:
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR!     nodemon ./src/server.js --exec babel-node -e js
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! You can get information on how to open an issue for this project with:
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR!     npm bugs my-api
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! Or if that isn't available, you can get their info via:
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR!     npm owner ls my-api
   2018-02-11T09:56:46.99-0500 [APP/PROC/WEB/0] ERR npm ERR! There is likely additional logging output above.
   2018-02-11T09:56:47.00-0500 [APP/PROC/WEB/0] ERR npm ERR! Please include the following file with any support request:
   2018-02-11T09:56:47.00-0500 [APP/PROC/WEB/0] ERR npm ERR!     /home/vcap/app/npm-debug.log
   2018-02-11T09:56:47.02-0500 [APP/PROC/WEB/0] OUT Exit status 1
   2018-02-11T09:56:47.03-0500 [CELL/0] OUT Exit status 0
   2018-02-11T09:56:47.04-0500 [CELL/0] OUT Stopping instance 9c032c0c-808a-4d3b-58c6-7a9d
   2018-02-11T09:56:47.04-0500 [CELL/0] OUT Destroying container
   2018-02-11T09:56:47.08-0500 [API/1] OUT Process has crashed with type: "web"
   2018-02-11T09:56:47.10-0500 [API/1] OUT App instance exited with guid 2ab9a2a6-d4e7-4f6c-a2a5-cb228507af6b payload: {"instance"=>"9c032c0c-808a-4d3b-58c6-7a9d", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>5, "crash_timestamp"=>1518361007050955995, "version"=>"d7f77b8a-4ed4-4b53-bd23-33e78b6a8883"}
   2018-02-11T09:56:48.91-0500 [CELL/0] OUT Successfully destroyed container

EDIT: Oddly enough, it worked when I manually did npm install:

#!/bin/bash
export PATH=/opt/IBM/node-v6.7.0/bin:$PATH  # added
npm install  # added
cf push "${CF_APP}"

However this is not a valid solution because the Cloud Foundry deploy is supposed to npm install for you, doing it like that makes the deploy take twice as long.


Solution

  • devDependencies do not get installed, so I had to move a few things to dependencies.