我有一个带有节点/表达服务器的reactjs应用程序。该应用程序在本地计算机上运行良好。将其很好地部署到Heroku时,它表示构建成功,但是当我访问应用程序网站时,出现“无法获取/”字样,并且在console.log中出现错误无法加载资源:服务器响应状态为404(未找到)。这就是我的目录树的样子,
这是我的根包的样子。我同时运行客户端和服务器,因此即时消息同时使用
{
"name": "xxxxxxxxxx",
"version": "0.1.0",
"private": true,
"engines": {
"node": "10.16.3"
},
"dependencies": {
"axios": "^0.19.0",
"concurrently": "^5.0.2",
"express": "^4.17.1",
"google-map-react": "^1.1.5",
"google-maps-react": "^2.0.2",
"jquery": "^3.4.1",
"materialize-css": "^1.0.0-rc.2",
"node-sass": "^4.13.0",
"nodemailer": "^6.3.1",
"nodemon": "^2.0.2",
"react": "^16.9.0",
"react-background-slideshow": "^1.0.4",
"react-dom": "^16.9.0",
"react-lightgallery": "^0.6.3",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"react-scroll-to-component": "^1.0.2",
"react-tooltip": "^3.11.2",
"uikit": "^3.1.8"
},
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client",
"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"
]
}
}
这是我在客户端文件夹中的包的样子
{
"name": "client",
"version": "1.0.0",
"proxy": "http://localhost:3001",
"description": "",
"main": "index.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"axios": "^0.19.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.1"
},
"author": "",
"license": "ISC"
}