lundi 4 janvier 2016

error deploying node.js app to heroku

I'm trying to deploy my node.js app to heroku. I'm getting this error on git push heroku master:

> on-headers@1.0.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/response-time/node_modules/on-headers
   > mocha --reporter spec --bail --check-leaks test/

   /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
   throw new Error("cannot resolve path (or pattern) '" + path + "'");
   ^

   Error: cannot resolve path (or pattern) 'test/'
   at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
   at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
   at Array.forEach (native)
   at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
   at Module._compile (module.js:435:26)
   at Object.Module._extensions..js (module.js:442:10)
   at Module.load (module.js:356:32)
   at Function.Module._load (module.js:311:12)
   at Function.Module.runMain (module.js:467:10)
   at startup (node.js:136:18)
   at node.js:963:3

   > node-statsd@0.1.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/soluto-monitor/node_modules/node-statsd
   > mocha -R spec

   /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
   throw new Error("cannot resolve path (or pattern) '" + path + "'");
   ^

   Error: cannot resolve path (or pattern) 'test'
   at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
   at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
   at Array.forEach (native)
   at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
   at Module._compile (module.js:435:26)
   at Object.Module._extensions..js (module.js:442:10)
   at Module.load (module.js:356:32)
   at Function.Module._load (module.js:311:12)
   at Function.Module.runMain (module.js:467:10)
   at startup (node.js:136:18)
   at node.js:963:3
...

..and on and on with the error Error: cannot resolve path (or pattern) 'test/' for each node_modules subdirectory.

my package.json looks like more or less like this:

{
  "name": "my-module",
  "version": "0.1.0",
  "description": "My Module",
 "dependencies": {
    "azure-storage": "0.6.0",
    "bluebird": "3.0.6",
    "body-parser": "1.14.1",
    "cors": "2.7.1",
    "dotenv": "^1.2.0",
    "express": "3.3.3",
    "moment": "2.10.6",
    "request-promise": "1.0.2",
    "rx": "4.0.7",
    "shisell": "0.0.2",
    "striptags": "2.0.4",
    "winston": "2.1.1"
  },
  "devDependencies": {
    "chai": "^3.4.1",
    "chai-as-promised": "^5.1.0",
    "mocha": "^2.3.4",
    "mock-require": "^1.2.1",
    "sinon": "^1.17.2",
    "sinon-chai": "^2.8.0",
    "supertest": "^1.1.0"
  },
  "main": "server.js",
  "engines": {
    "node": "4.2.3"
  },
  "scripts": {
    "test": "mocha"
  }
}

it seems like mocha is trying to run from within node_modules, inside each dependency. i managed to reproduce the error locally by running mocha from within one of the node_modules directories.

I tried removing test script from my package.json and I still get the same error.

I'm new to heroku deployments. As far as I understood once I git push to heroku then heroku runs npm install and if there is a test script it will run. But I don't understand what causes it to try and run mocha within subdirectories of node_modules (and why that would happen even if I don't specify a test script inside my package.json).

Any ideas?

p.s. this doesn't happen when I run locally on my machine.

Aucun commentaire:

Enregistrer un commentaire