我按照说明,将 repo 推送到 heroku,我发现它崩溃了。我使用 heroku/nodejs 作为构建包。
简介:
web: npm run build && npm run heroku-server
脚本:
"scripts": {
"heroku-server": "cross-env SERVER_PROD_PORT=$PORT SERVER_PROD_HOST=0.0.0.0 npm run server",
"browser": "cross-env NODE_ENV=development WEBPACK_CONFIG=browser_dev webpack-dev-server --open",
"build": "cross-env NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_prod webpack --colors",
"build-analyze": "cross-env BUNDLE_ANALYZER=1 NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_prod webpack --colors",
"build-browser": "cross-env NODE_ENV=production WEBPACK_CONFIG=browser_prod webpack --colors",
"build-run": "npm run build && npm run server",
"build-static": "cross-env NODE_ENV=production WEBPACK_CONFIG=static webpack --colors",
"build-static-run": "npm run build-static && npm run static",
"clean": "rimraf dist",
"lint": "eslint .",
"server": "node dist/server",
当我从 Procfile 或 $ heroku local web 运行脚本时,一切都很好。但是推送的 repo 在日志中抛出错误:
2018-01-30T22:23:05.780537+00:00 heroku[web.1]: Starting process with command `npm run build && npm run heroku-server`
2018-01-30T22:23:07.502982+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-30T22:23:07.491558+00:00 heroku[web.1]: Process exited with status 1
2018-01-30T22:23:07.292672+00:00 app[web.1]:
2018-01-30T22:23:07.292693+00:00 app[web.1]: > beers@2.10.0 build /app
2018-01-30T22:23:07.292694+00:00 app[web.1]: > cross-env NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_prod webpack --colors
2018-01-30T22:23:07.292695+00:00 app[web.1]:
2018-01-30T22:23:07.421065+00:00 app[web.1]: events.js:137
2018-01-30T22:23:07.421068+00:00 app[web.1]: throw er; // Unhandled 'error' event
2018-01-30T22:23:07.421070+00:00 app[web.1]: ^
2018-01-30T22:23:07.421071+00:00 app[web.1]:
2018-01-30T22:23:07.421073+00:00 app[web.1]: Error: spawn webpack ENOENT
2018-01-30T22:23:07.421074+00:00 app[web.1]: at _errnoException (util.js:1003:13)
2018-01-30T22:23:07.421076+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
2018-01-30T22:23:07.421078+00:00 app[web.1]: at onErrorNT (internal/child_process.js:389:16)
2018-01-30T22:23:07.421080+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:152:19)
2018-01-30T22:23:07.421081+00:00 app[web.1]: at Function.Module.runMain (module.js:703:11)
2018-01-30T22:23:07.421083+00:00 app[web.1]: at startup (bootstrap_node.js:193:16)
2018-01-30T22:23:07.421085+00:00 app[web.1]: at bootstrap_node.js:617:3
2018-01-30T22:23:07.426513+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-01-30T22:23:07.426855+00:00 app[web.1]: npm ERR! errno 1
2018-01-30T22:23:07.428042+00:00 app[web.1]: npm ERR! beers@2.10.0 build: `cross-env NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_prod webpack --colors`
我错过了什么?