inconsistent error cannot find module

时间:2016-10-20 12:38:31

标签: node.js

I've created a module of my own, let's call him X.

I'm using crontab to run proccesses repeatedly.

Sometimes a proccess might throw an error that he cannot find my module X.

20 10 2016 09:01:06.815 (production) (i-8e4) ERROR console - update.js ERROR: Error: Cannot find module 'X' stack: Error: Cannot find module 'X'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/git/repo/update.js:3:14)
    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 Module.require (module.js:366:17)

I find that odd since the proccessess are running most of times, probably more then 90% of the times.

I think this is aproblem with packages..

So heres the package.json of module X:

{
  "name": "X",
  "version": "0.8.2",
  "description": "a Library",
  "dependencies": {
    "async": "^1.4.2",
    "aws-sdk": "^2.2.12",
    "colors": "^1.1.2",
    "cron": "^1.0.9",
    "csv": "^0.4.6",
    "geoip-lite": "^1.1.6",
    "hiredis": "^0.4.1",
    "ipaddr.js": "^1.0.3",
    "lodash": "^3.10.1",
    "log4js": "^0.6.27",
    "mobile-detect": "^1.3.0",
    "mysql": "^2.9.0",
    "node-schedule": "^1.0.0",
    "node-timeout": "0.0.4",
    "nodemailer": "^1.8.0",
    "nodemailer-ses-transport": "^1.3.0",
    "password-hash": "^1.2.2",
    "path-extra": "^2.0.0",
    "pg": "^4.4.2",
    "qs": "^5.2.0",
    "redis": "^2.2.5",
    "request": "^2.65.0",
    "request-ip": "^1.1.4",
    "s3": "^4.4.0",
    "ua-parser-js": "^0.7.9"
  },
  "devDependencies": {
    "eslint": "^1.6.0",
    "it-each": "^0.3.1",
    "jscs": "^2.3.0"
  }
}

main module package.json(it has several proccess that require X)

{
  "name": "Main module",
  "version": "1.1.6",
  "description": "Main module crontab runs his processess that require module X",
  "main": "index.js",
  "dependencies": {
    "async": "^1.5.0",
    "chai": "^3.5.0",
    "cron": "^1.1.0",
    "lodash": "^3.10.1",
    "mock-globals": "^0.1.3",
    "moment": "^2.13.0",
    "node-timeout": "0.0.4",
    "nodemailer": "^1.8.0",
    "nodemailer-ses-transport": "^1.3.0",
    "proxyquire": "^1.7.10",
    "redis-mock": "^0.10.0",
    "X": "git+ssh://git@github.com:X.git#v0.8.2"
  }
}

Having some trouble with this error since it is only happening on production instance.. Any ideas on how to debug/solve this?

Thanks!

0 个答案:

没有答案