【发布时间】:2020-12-29 14:05:54
【问题描述】:
根据How to upgrade a React project built with create-react-app,我已将 react-scripts 从 v1.1.4 更新到 v3.4.3。但是,主页上有一个问题我无法正确解决。
在之前的 package.json 中,我有 "homepage": "/temp_project/resources"
在我将 react-scripts 更新到 v3.4.3 之后,一切正常,除了
当 npm start ("start": "react-scripts start") 时,路径将变为 http://localhost:3000/temp_project/resources
这是意料之中的。 (预计有 http://localhost:3000/ )
Hot fix = 每次手动将路径更改为 http://localhost:3000/
如果我将"homepage": "/temp_project/resources" 更改为"homepage": "/",那么我的http://localhost:8080/temp_project(索引页)就会变成一个空白页。我的 npm start ("start": "react-scripts start") 工作正常。
我该怎么办??对不起,如果这是一个愚蠢的问题。谢谢。
补充:
这是一个使用 eirslett/frontend-maven-plugin 的 maven spring boot 项目 和maven-resources-plugin
package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"homepage": "/temp_project/resources",
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
【问题讨论】:
标签: reactjs npm create-react-app package.json