在多次成功构建之后,每当我的Node应用程序部署到Heroku时,我突然都遇到构建错误。我收到提示
的构建失败错误2018-10-07T20:40:50.484403+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-07T20:41:10.730943+00:00 heroku[web.1]: Starting process with command `node ./index.js`
2018-10-07T20:41:15.939290+00:00 heroku[web.1]: Process exited with status 1
2018-10-07T20:41:15.958229+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-07T20:41:15.841898+00:00 app[web.1]: module.js:487
2018-10-07T20:41:15.841925+00:00 app[web.1]: throw err;
2018-10-07T20:41:15.841926+00:00 app[web.1]: ^
2018-10-07T20:41:15.841927+00:00 app[web.1]:
2018-10-07T20:41:15.841935+00:00 app[web.1]: Error: Cannot find module 'sax'
2018-10-07T20:41:15.841942+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:485:15)
2018-10-07T20:41:15.841949+00:00 app[web.1]: at Function.Module._load (module.js:437:25)
2018-10-07T20:41:15.841951+00:00 app[web.1]: at Module.require (module.js:513:17)
2018-10-07T20:41:15.841952+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-10-07T20:41:15.841958+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/xml2js/lib/parser.js:9:9)
2018-10-07T20:41:15.841960+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/xml2js/lib/parser.js:357:4)
2018-10-07T20:41:15.841961+00:00 app[web.1]: at Module._compile (module.js:569:30)
2018-10-07T20:41:15.841962+00:00 app[web.1]: at Object.Module._extensions..js (module.js:580:10)
2018-10-07T20:41:15.841964+00:00 app[web.1]: at Module.load (module.js:503:32)
2018-10-07T20:41:15.841965+00:00 app[web.1]: at tryModuleLoad (module.js:466:12)
2018-10-07T20:41:15.841966+00:00 app[web.1]: at Function.Module._load (module.js:458:3)
2018-10-07T20:41:15.841968+00:00 app[web.1]: at Module.require (module.js:513:17)
2018-10-07T20:41:15.841969+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-10-07T20:41:15.841972+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/xml2js/lib/xml2js.js:37:4)
2018-10-07T20:41:15.841971+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/xml2js/lib/xml2js.js:12:12)
这些是我的package.json依赖项:
"dependencies": {
"apollo-server-express": "^2.0.6",
"aws-sdk": "^2.315.0",
"bcrypt": "^3.0.0",
"body-parser": "^1.18.3",
"concurrently": "^3.6.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.3",
"cors": "^2.8.4",
"express": "^4.16.3",
"express-router": "0.0.1",
"express-session": "^1.15.6",
"frontend": "file:client",
"graphql": "^0.13.2",
"mongoose": "^5.2.14",
"multer": "^1.3.1",
"multer-s3": "^2.7.0",
"passport": "^0.4.0",
"passport-facebook": "^2.1.1",
"passport-google-oauth20": "^1.0.0",
"passport-local": "^1.0.0",
"path": "^0.12.7"
},
"devDependencies": {
"nodemon": "^1.18.3"
}
我假设sax是我的依赖项之一的依赖项。我尝试销毁该应用程序并重新部署,并尝试验证我的版本和兼容性(据我所知)。该应用程序在前50个左右的部署中运行良好,但随后突然开始抛出这些错误,除了实际代码(主要是前端)之外,我的应用程序(我可以看到)中没有任何变化。自从上次运行以来,依赖项没有任何变化或类似的变化。
我所有的依赖项都在package.json中的依赖项对象中(devDependencies中唯一的东西是nodemon)。我今天想到的一件事,但不确定是原因还是相关原因(尽管看起来确实相关,值得一提),我一直在与git发生很多package-lock.json冲突。我和我的伙伴正在为此工作,并且都从同一存储库中进行推/拉操作(他负责前端/反应的工作,而我专注于后端)。但是,从他的更改中提取的所有内容都导致了包锁冲突,当我推送更改时,这对他也一样(我们都运行相同版本的npm和node)。同样,我不确定这是否是此问题的一部分,但这似乎是偶然的。