我有一个使用CRA Cli引导的反应项目。我有CI的travis和在Heroku上部署。该项目已经运行了大约一个月。最后一次构建大约是25天前,它已经过去了。今天,当我访问这个应用程序时,它正在破碎。当我重建和重新部署时,重建工作,在某种程度上部署和错误
错误R10(启动超时) - > Web进程无法在启动后60秒内绑定到$ PORT
自25天前的最后一次推送以来,我已将任何内容合并到master中,所以我很确定没有代码可以获取源代码控制并搞砸了。
这是我的package.json(只是相关部分)
"dependencies": {
"axios": "^0.18.0",
"leaflet": "^1.3.1",
"lodash": "^4.17.5",
"npm-run-all": "^4.1.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-leaflet": "^1.9.0",
"react-redux": "^5.0.7",
"react-scripts": "1.1.1",
"react-tabs": "^2.2.1",
"react-tabs-redux": "^2.0.1",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"socket.io-client": "^2.1.0",
"thunk": "0.0.1"
},
"scripts": {
"start": "npm-run-all -p watch-css start-js",
"build": "npm-run-all build-css build-js",
"start-js": "react-scripts start",
"build-js": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"test-ci": "CI=true react-scripts test --env=jsdom --ci",
"eject": "react-scripts eject",
"build-css": "node-sass-chokidar src/ -o src/ --quiet",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"lint": "./node_modules/.bin/eslint src/**/*.js",
"prettier": "prettier --write --tab-width=2 --single-quote=true \"src/**/*.{js,scss}\""
},
这是我的index.js(仅限相关部分)
if (process.env.NODE_ENV === 'development') {
middleware = [logger];
}
const store = createStore(
rootReducer,
composeWithDevTools(applyMiddleware(thunk, ...middleware))
);
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
和Procfile
web: npm i -g serve && npm run build && serve -s build
从日志中可以看出
处的连接
问题
答案 0 :(得分:0)
请检查您一定错过的创建服务器代码 process.env.PORT
Heroku动态分配一个从env变量中提取的端口。你的代码应该是这样的:
.listen(process.env.PORT || 3000)