Reactjs 在部署到heroku并运行npm构建后对应用程序进行更改
我将REACT应用程序部署到Heroku,一切正常,但如何在本地运行它并进行更改?当我使用npm start时,它在端口8080(教程告诉我要使用的端口)上启动,但在3000上不启动。当我到达localhost:8080时,我的网站在那里,但我所做的任何更改即使在刷新后也不会显示出来 我只想在本地进行更改,然后将更改重新部署到HerokuReactjs 在部署到heroku并运行npm构建后对应用程序进行更改,reactjs,heroku,deployment,Reactjs,Heroku,Deployment,我将REACT应用程序部署到Heroku,一切正常,但如何在本地运行它并进行更改?当我使用npm start时,它在端口8080(教程告诉我要使用的端口)上启动,但在3000上不启动。当我到达localhost:8080时,我的网站在那里,但我所做的任何更改即使在刷新后也不会显示出来 我只想在本地进行更改,然后将更改重新部署到Heroku Here is my server.js const express = require('express'); const favico
Here is my server.js
const express = require('express');
const favicon = require('express-favicon');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();
app.use(favicon(__dirname + '/build/favicon.ico'));
// the __dirname is the current directory from where the script is running
app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, 'build')));
app.get('/ping', function (req, res) {
return res.send('pong');
});
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(port);
Here is my package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.9.9",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"aphrodite": "^2.4.0",
"express": "^4.17.1",
"express-favicon": "^2.0.1",
"path": "^0.12.7",
"react": "^16.13.1",
"react-animate-on-scroll": "^2.1.5",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "node server.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
您在本地所做的任何更改都不能单独反映在服务器中
每次创建新版本时,必须使用git将更改部署到服务器上,或仅部署生成文件夹。您在本地所做的任何更改都无法在服务器中单独反映出来
每次创建新版本时,您必须使用git将更改部署到服务器上,或者只部署build文件夹。但是如何再次在本地运行项目,以便查看更改,然后重新部署到Heroku?我不明白。你最初是如何部署的??你必须先检查一下,对吗?但我如何在本地再次运行项目,以便看到更改,然后重新部署到Heroku?我不明白。你最初是如何部署的??你必须先检查一下,对吗?