![](/img/trans.png)
[英]What changes should I make in the script of the package.json file of a MERN app before deploying on Heroku?
[英]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"
}
}
根据我的测试你可以这样做:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.