Owe*_*oco 12 heroku node.js reactjs
该应用程序在 Windows 中的“npm start”之后运行良好,但是当我从 github 拉入 Heroku 时,我只是收到一个错误。
包.json:
{
"name": "tic-tac-toe",
"version": "0.1.0",
"dependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"engines": {
"node": "6.10.3",
"npm":"3.10.10"
},
"devDependencies": {
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Run Code Online (Sandbox Code Playgroud)
和错误日志:
app[web.1]: npm ERR! npm bugs tic-tac-toe
app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
app[web.1]: npm ERR! npm owner ls tic-tac-toe
app[web.1]: npm ERR! There is likely additional logging output above.
app[web.1]:
app[web.1]: npm ERR! Please include the following file with any support request:
app[web.1]: npm ERR! /app/npm-debug.log
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=react-tac-to.herokuapp.com request_id=c3cf2461-1989-4734-a7d5-157eb81c9643 fwd="24.29.73.46" dyno= connect= service= status=503 bytes= protocol=https
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=react-tac-to.herokuapp.com request_id=05109629-cbb4-4927-9d13-8a3a37fedb93 fwd="24.29.73.46" dyno= connect= service= status=503 bytes= protocol=https
Run Code Online (Sandbox Code Playgroud)
问题的本质让我认为这是基于配置的,而不是主要的 app.js 代码。主文件有点长,如果你想看,我会在 Github 上链接到它:https : //github.com/owenpercoco/React-Tac-Toe
小智 19
我遇到了同样的问题,但上面的解决方案对我在 Heroku 中的 react 应用程序不起作用。我已将构建包更新为 create-react-app,它对我有用。
heroku buildpacks:set mars/create-react-app
Suf*_*lim 17
只是npm i serve为了安装服务,或者你可以使用纱线而不是 npm
您可以在 package.json 文件中更改您的脚本,这似乎是由 react 更新引起的。
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"heroku-postbuild": "npm run build"}
Run Code Online (Sandbox Code Playgroud)
希望它能解决您的问题。
Beh*_*rak 10
1.)npm install serve --save或yarn install serve --save在您的终端中
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}
Run Code Online (Sandbox Code Playgroud)
2.)复制上面的代码来代替我的 package.json 文件中以前的代码“脚本”
3.)git commit -am "new update"
4.)git push heroku master
Heroku 默认情况下不安装开发依赖项:。https://devcenter.heroku.com/articles/nodejs-support。将您的react-scripts模块设置为始终安装或关闭Heroku上的生产模式。
小智 6
我面临同样的问题,它对我有用。
将“服务”添加到应用程序中。
例子:
npm add serve or yarn add serve
更改 package.json 中的脚本后
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"heroku-postbuild": "npm run build"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11740 次 |
| 最近记录: |