簡體   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