由于node_modules,Heroku node.js一直崩溃?

时间:2017-12-13 16:14:46

标签: node.js heroku

这是heroku日志

2017-12-13T16:08:29.000000+00:00 app[api]: Build succeeded
2017-12-13T16:08:46.328161+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-12-13T16:08:46.498068+00:00 heroku[web.1]: Process exited with status 143
2017-12-13T16:08:53.490378+00:00 app[web.1]: module.js:538
2017-12-13T16:08:53.490391+00:00 app[web.1]:     throw err;
2017-12-13T16:08:53.490391+00:00 app[web.1]:     ^
2017-12-13T16:08:53.490392+00:00 app[web.1]: 
2017-12-13T16:08:53.490392+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:08:53.490393+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:08:53.490394+00:00 app[web.1]:     at Function.Module._load (module.js:466:25)
2017-12-13T16:08:53.490394+00:00 app[web.1]:     at Module.require (module.js:579:17)
2017-12-13T16:08:53.490395+00:00 app[web.1]:     at require (internal/module.js:11:18)
2017-12-13T16:08:53.490395+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:08:53.490396+00:00 app[web.1]:     at Module._compile (module.js:635:30)
2017-12-13T16:08:53.490396+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:08:53.490397+00:00 app[web.1]:     at Module.load (module.js:554:32)
2017-12-13T16:08:53.490397+00:00 app[web.1]:     at tryModuleLoad (module.js:497:12)
2017-12-13T16:08:53.490398+00:00 app[web.1]:     at Function.Module._load (module.js:489:3)
2017-12-13T16:08:53.582814+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-13T16:08:53.555998+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:08:51.503070+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:20.313936+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-13T16:10:23.590155+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:26.548414+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:10:26.463026+00:00 app[web.1]: module.js:538
2017-12-13T16:10:26.463042+00:00 app[web.1]:     throw err;
2017-12-13T16:10:26.463042+00:00 app[web.1]:     ^
2017-12-13T16:10:26.463043+00:00 app[web.1]: 
2017-12-13T16:10:26.463044+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:10:26.463045+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:10:26.463045+00:00 app[web.1]:     at Function.Module._load (module.js:466:25)
2017-12-13T16:10:26.463046+00:00 app[web.1]:     at Module.require (module.js:579:17)
2017-12-13T16:10:26.463046+00:00 app[web.1]:     at require (internal/module.js:11:18)
2017-12-13T16:10:26.463047+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:10:26.463048+00:00 app[web.1]:     at Module._compile (module.js:635:30)
2017-12-13T16:10:26.463048+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:10:26.463049+00:00 app[web.1]:     at Module.load (module.js:554:32)
2017-12-13T16:10:26.463050+00:00 app[web.1]:     at tryModuleLoad (module.js:497:12)
2017-12-13T16:10:26.463050+00:00 app[web.1]:     at Function.Module._load (module.js:489:3)
2017-12-13T16:10:26.576992+00:00 heroku[web.1]: State changed from starting to crashed

通过试验和错误并使用heroku回滚,似乎问题不在我的app.js文件中,而是在node_modules中。但是我似乎找不到修复方法。我已经尝试重新安装node_modules。

它在本地工作,但在Heroku上部署时却没有。

突然间我有一个package-lock.json文件。也许那是一个线索?

2 个答案:

答案 0 :(得分:0)

它抱怨decimal128模块,我会从需要它的文件中仔细检查模块的相对路径。现在看起来它正在与文件“/ decimal128”相同的文件夹中查找。

答案 1 :(得分:0)

我通过更新所有内容并将mongodb降级为“mongodb”来修复它:“2.2.33”