我有一个React应用程序:http://we ****。com / buzz /
上面的网址显示它已部署在(base) C:\Users\companyadmin>conda update -n base conda
Solving environment: done
## Package Plan ##
environment location: C:\ProgramData\Anaconda3
added / updated specs:
- conda
The following packages will be downloaded:
package | build
---------------------------|-----------------
conda-4.6.14 | py36_0 2.1 MB
The following packages will be UPDATED:
conda: 4.4.10-py36_0 --> 4.6.14-py36_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
conda 4.6.14: ######################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(481): An error occurred while uninstalling packag
e 'defaults::conda-4.4.10-py36_0'.
PermissionError(13, 'Access is denied')
Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Access is denied')
文件夹下。
在浏览器中只有buzz
和displays blank page
。
我已经在package.json中设置了no console error
变量,并且所有URL似乎都没问题。
有人可以让我知道这个问题吗?
我的package.json文件是:
homepage
我的路线文件::
{
"name": "buzz",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"homepage": "http://we****.com/buzz/",
"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"
]
}
}
答案 0 :(得分:0)
我通过做两件事解决了这个问题:
1)在package.json文件中设置以下代码
"homepage": "http://we****.com/buzz/"
2)在路由文件的BrowserRouter中设置基本名称:
export default class Routes extends Component {
render() {
return (
<BrowserRouter basename={'/buzz'}>
<Switch>
<Route exact path="/" component={HomeComponent} />
<Route exact path="/login" component={LoginComponent} />
<Route exact path="/signup" component={SignupComponent} />
<Route exact path="/mystories" component={MyStoriesComponent} />
<Route exact path="/addstory" component={AddStoryComponent} />
{/*<Route exact path="/listPartnerAccount/:id" component={ListPartnerAccount} />*/}
</Switch>
</BrowserRouter>
);
}
}
请注意,仅在package.json文件中设置主页对我不起作用,这是上述两个步骤的组合对我有用。
答案 1 :(得分:0)
如果将构建文件上传到该目录(http://*****.com/buzz/),此方法应该可以正常工作。
请先确认在package.json上添加主页后,您可以构建应用。命令为(yarn run build OR yarn build),之后将文件从构建目录上载到所需位置。