节点js错误需要模块

时间:2017-09-22 10:47:00

标签: javascript node.js npm hummus.js

我创建了一个包括使用hummus.js的API。在本地测试之后,我在我的服务器上上传了新的API Build(Ubuntu Root + Plesk Onyx),然后npm安装我的package.json(使用Plesk =>输出:安装完成状态:成功)。但是我的新版Build不起作用。调试我的代码后,我检测到错误。在需要一个模块(使用该代码测试)后,我的API出现内部错误

try {
 var hummus = require('hummus');
 var fillClass = require('../classes/fillform').fillForm;
    }
    catch (e) {
    res.send("ERROR HUMMUS")
    }

运行此代码我得= ERROR HUMMUS

我认为鹰嘴豆泥的道路并不存在,只有:

 try {
      res.send(require.resolve("hummus")).end();
  } catch(e) {
      res.send("not found").end();
      process.exit(e.code);
  }

我得到了模块的路径(鹰嘴豆泥)。虽然此文件夹中的所有文件都存在。

(async,fs等其他模块效果很好)

我做错了什么?我该怎么办?

问候

编辑Package.json   {"name": "XXX-API", "version": "1.0.9", "main": "server.js", "dependencies": { "archiver": "^2.0.0", "array-sum": "^1.0.0", "async": "^2.5.0", "big-integer": "^1.6.24", "body-parser": "^1.17.2", "child_process": "^1.0.2", "cors": "^2.8.3", "curl": "^0.1.4", "express": "^4.15.3", "file-encryptor": "^0.1.1", "fs": "0.0.1-security", "ftp": "^0.3.10", "ftp-client": "^0.2.2", "ftps": "^1.1.0", "german-tax-id-validator": "^1.0.3", "https": "^1.0.0", "hummus": "^1.0.80", "ibantools": "^1.3.0", "jsftp": "^2.0.0", "leading-zeros": "^1.0.1", "lodash": "^4.17.4", "mysql": "^2.13.0", "node-datetime": "^2.0.0", "node-pdffiller": "0.0.7", "node-uuid": "^1.4.8", "node-zip": "^1.1.1", "nodemailer": "^4.0.1", "pad-right": "^0.2.2", "pdfkit": "^0.8.3", "phantomjs": "^2.1.7", "pug": "^2.0.0-rc.2", "request-promise": "^4.2.1", "requestify": "^0.2.5", "shortid": "^2.2.8", "slack-node": "^0.1.8", "uid": "0.0.2", "xmlbuilder": "^9.0.4" } }

1 个答案:

答案 0 :(得分:0)

请将错误写入日志。

... catch (err){
   logger.debug(err.stack)
}

没有比错误堆栈更好的方法。