【发布时间】: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