【发布时间】:2019-09-14 19:51:01
【问题描述】:
我用 react.js 创建了一个应用程序。我想投入生产。
我做到了
npm run build
serve -s build
我继续localhost:5000
欢迎页面效果很好,但是当我继续localhost:5000/main时出现错误
404 | The requested path could not be found
我尝试重做npm run build,但没有成功
你有什么建议?
编辑
包.json
{
"name": "name-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^5.10.0",
"node-sass": "^4.11.0",
"p5": "^0.8.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-p5-wrapper": "0.0.4",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"socket.io-client": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
"main": "index.js",
"devDependencies": {},
"author": "",
"license": "ISC"
}
【问题讨论】:
-
请分享
run build的 package.json 规格同时在 chrome 开发人员工具上检查引发错误的 url,也许你没有指向 /build/ -
我添加了package.json,chrome开发者没有错误
-
你是否在你的 react 应用中为“/main”设置了路由?您是否期望“/main”会加载 index.js?
-
在投入生产之前一切正常,但在 npm run build 之后它就不再工作了
标签: javascript reactjs dev-to-production