繁体   English   中英

如何更改部署在 heroku 上的 mern 应用程序以及如何在将其部署到生产环境之前检查更改?

[英]How to make changes to mern app deployed on heroku and how to check the changes before I deploy it in production?

让我进一步解释一下,我的意思是我创建了一个已经部署在 heroku 上的 mern 应用程序,现在我想在应用程序中进行更改,但在我再次将其推送到 heroku 之前,我想在本地检查我的更改,我该怎么做那? 我尝试了 heroku 本地命令,但它启动客户端并且无法获取节点服务器路由请在这里帮帮我?:这是我的代码:

节点应用程序.js

import express from "express";
import bodyParser from "body-parser";       
import dotenv from 'dotenv'
import router from './Routes/auth.js'
import path from 'path';

dotenv.config({path:'./config.env'});

const host = '0.0.0.0';
const port = process.env.PORT || 5000;
const app= express()
app.use(router);

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

app.listen(port,host,()=>{
    console.log(`Server Started Succesfully on port number ${port}`);
})  

package.jso(nodejs)

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npx nodemon app.js",
    "client":"npm start --prefix client",
    "dev":"concurrently \"npm start\" \"npm run client\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.1",
    "cookie-parser": "^1.4.6",
    "dotenv": "^10.0.0",
    "express": "^4.17.2",
    "jsonwebtoken": "^8.5.1",
    "moment": "^2.29.1",
    "mongoose": "^6.1.8"
  }
}

我的文件系统

根据我的测试你可以这样做:

  1. 检查浏览器工具:例如响应性
  2. 在 DevTools 中检查您的元素
  3. 所有页面所有 Div 标记元素、应用程序的响应性和设计,您可以检查您的应用程序
  4. 对于节点服务器路由,您可以通过在 Postman API 工具中对其进行测试来检查
  5. 准备部署

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM