首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Heroku网站:启动脚本失败

Heroku网站:启动脚本失败
EN

Stack Overflow用户
提问于 2019-04-11 13:53:11
回答 1查看 9.3K关注 0票数 2

我来接这个

在sequelize@1.0.0启动脚本时失败。

当部署一个快递+反应应用程序。我认为heroku和concurrently有问题。

我做错什么了?我引用了this,但是这个解决方案与这个应用程序有点无关。

也引用了这个

https://medium.freecodecamp.org/how-to-deploy-a-react-app-with-an-express-server-on-heroku-32244fe5a250

根文件夹package.json

代码语言:javascript
复制
{
  "name": "sequelize-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "client-install": "npm install --prefix client",
    "build": "concurrently \"cd client && npm run build\" \"npm build \"",
    "test": "echo \"Error: no test specified\" && exit 1",
    "client": "cd ./client && npm start ",
    "server-prod": "node app.js",
    "server": "nodemon app.js",
    "start": "concurrently --kill-others  \"npm run client\" \"npm run server\" ",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async": "^2.6.1",
    "bcrypt": "^3.0.2",
    "body-parser": "^1.18.3",
    "concurrently": "^4.1.0",
    "cookie-parser": "^1.4.3",
    "cookie-session": "^2.0.0-beta.3",
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^7.0.0",
    "express": "^4.16.4",
    "express-flash": "0.0.2",
    "express-session": "^1.15.6",
    "foreman": "^3.0.1",
    "jsonwebtoken": "^8.4.0",
    "morgan": "^1.9.1",
    "nodemailer": "^5.1.1",
    "nodemon": "^1.18.9",
    "passport": "^0.4.0",
    "passport-github": "^1.1.0",
    "passport-github2": "^0.1.11",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "pg": "7.9.0",
    "pg-hstore": "^2.3.2",
    "sequelize": "^4.42.0",
    "sequelize-cli": "^5.4.0"
  },
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^6.1.2"
  }
}

client/package.json

代码语言:javascript
复制
{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:8000",
  "dependencies": {
    "@material-ui/core": "^3.9.1",
    "@material-ui/icons": "^3.0.2",
    "axios": "^0.18.0",
    "history": "^4.7.2",
    "http-proxy-middleware": "^0.19.1",
    "jsonwebtoken": "^8.4.0",
    "jwt-decode": "^2.2.0",
    "material-ui-icons": "^1.0.0-beta.36",
    "moment": "^2.24.0",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-redux": "^6.0.0",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.3",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0",
    "superagent": "^4.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "heroku-postbuild": "npm run build"
  },
  
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "dotenv": "^6.2.0"
  }
}

Profile

代码语言:javascript
复制
web: npm run start

日志

已创建了用户db和user表。 状态从开始到上升 端口32000上已经有东西在运行。 npm运行客户端退出代码0 将SIGTERM发送到其他进程。 npm运行服务器同时退出代码SIGTERM npm ERR! sequelize-demo@1.0.0 start:--杀死-其他"npm运行客户端“"npm运行服务器” npm错误!退出状态1 2019-04-11T07:26:41.326088+00:00附录1: 国家预防机制错误2019年-04-11T07:26:41.326282+00:00附录1: npm错误!在sequelize@1.0.0启动脚本时失败。

EN

回答 1

Stack Overflow用户

发布于 2019-04-11 14:55:15

修正了,我没有反应。

这就是我从

https://medium.freecodecamp.org/how-to-deploy-a-react-app-with-an-express-server-on-heroku-32244fe5a250

现在,在将项目推送到Heroku存储库之前,我们需要确保项目中有一个构建文件夹。将下面的脚本添加到您的package.json文件中--博客的作者

因此,我在客户端目录上进行了npm运行构建。

然后将我的package.json更改为

代码语言:javascript
复制
{
  "name": "sequelize-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "client-install": "npm install --prefix client",
    "build": "concurrently \"cd client && npm run build\" \"npm build \"",
    "test": "echo \"Error: no test specified\" && exit 1",
    "client": "cd ./client && npm start ",
    "server-prod": "node app.js",
    "server": "nodemon app.js",
    "start": "node app.js",
    "start:dev": "concurrently --kill-others  \"npm run client\" \"npm run server\" ",
    "heroku-postbuild":"NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async": "^2.6.1",
    "bcrypt": "^3.0.2",
    "body-parser": "^1.18.3",
    "concurrently": "^4.1.0",
    "cookie-parser": "^1.4.3",
    "cookie-session": "^2.0.0-beta.3",
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^7.0.0",
    "express": "^4.16.4",
    "express-flash": "0.0.2",
    "express-session": "^1.15.6",
    "foreman": "^3.0.1",
    "jsonwebtoken": "^8.4.0",
    "morgan": "^1.9.1",
    "nodemailer": "^5.1.1",
    "nodemon": "^1.18.9",
    "passport": "^0.4.0",
    "passport-github": "^1.1.0",
    "passport-github2": "^0.1.11",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "pg": "7.9.0",
    "pg-hstore": "^2.3.2",
    "sequelize": "^4.42.0",
    "sequelize-cli": "^5.4.0"
  },
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^6.1.2"
  }
}

将此添加到app.js

代码语言:javascript
复制
app.use(express.static(path.join(__dirname, 'client/build')));

if(process.env.NODE_ENV === 'production') {
  app.use(express.static(path.join(__dirname, 'client/build')));
  //
  app.get('*', (req, res) => {
    res.sendfile(path.join(__dirname = 'client/build/index.html'));
  })
}
//build mode
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname+'/client/public/index.html'));
})

Profile

代码语言:javascript
复制
web: npm start
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55634179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档