【问题标题】:Heroku git push heroku master runs cd client && npm run build non stopHeroku git push heroku master 运行 cd client && npm run build 不停
【发布时间】:2020-08-22 21:48:32
【问题描述】:

所以我遇到了问题。

我尝试将我的 MERN 应用程序部署到 Heroku。

所以当我执行git push heroku master 时,它运行正常,但随后它在循环 cd client && npm run build 中运行。

我不知道为什么。

你们中有人认识吗?

这是我的节点:

const PORT = process.env.PORT || 8080;

mongoose.connect('my mongo db', {useNewUrlParser: true})

app.use(passport.initialize());
app.use(passport.session());
app.use(session({
    resave: false,
    saveUninitialized: false,
    secret: 'secret here',
    store: new MongoStore({ mongooseConnection: mongoose.connection })
}))

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.use('/', indexRouter);
app.use('/authentication', usersRouter);

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('client/build'))
}

app.listen(PORT);

module.exports = app

这是我的包裹:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon app.js",
    "build": "cd client && npm run build",
    "install-client": "cd client && npm install",
    "heroku-postbuild": "npm run install-client && npm run build"
  },

我只发布了所需的代码,而不是我的全部代码,如果您需要的东西丢失,请告诉我!

-谢谢

【问题讨论】:

  • 我也遇到了同样的问题。

标签: node.js git heroku push mern


【解决方案1】:

我有同样的问题,我有一个内部 create-react-app 作为客户端文件夹。 由于某种原因,客户端文件夹在推送整个项目后没有进入主分支,包括服务器。 从客户端文件夹中删除 .git 文件夹后,问题解决了。

【讨论】:

    【解决方案2】:

    我遇到了这个问题,客户端文件夹中的另一个 .git 文件夹。删除那个文件夹 使用命令: Heroku 插件:安装,Heroku 构建 Heroku 构建:取消,Heroku 重新启动再次推送 Heroku 它将正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-19
      • 2011-05-23
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2021-05-19
      相关资源
      最近更新 更多