reactjs - 在反应应用程序中向 package.json 添加主页字段而不是转换为构建
问题描述
我正在尝试使用 cPanel 向 GoDaddy 启动 React 应用程序(create-react-app),但在创建正确的版本时遇到问题。我在 package.json 中的“名称”和“版本”下面设置主页(不确定这里的顺序是否重要),如下所示:
"homepage": "http://mydomainname.org"
但是,当我跑步时npm run build
,我收到一条消息说"The project was built assuming it is hosted at /. You can control this with the homepage field in your package.json.
有没有人遇到过这个问题?
解决方案
该消息不是错误。运行npm run build
命令后,应该会出现一个名为 build 的文件夹,其中包含您的 react 应用程序。您需要将该文件夹的内容上传到 cpanel 文件管理器中的 public_html 文件夹。(确保您上传的是构建文件夹中的内容,而不是构建文件夹本身)。这是一个简短教程的链接
推荐阅读
- javascript - Javascript使用PHP Echo从文件中打印innerHTML中的行
- dart - 无法获取 cmap 表大小!飘飘然
- c - 为什么我们不应该将定义放在标题中?
- graph - 如何根据 Neo4j 中最顶层的父节点检索节点
- c# - ActivityNotFoundException 未知原因
- php - strtotime() 期望参数 1 是字符串
- c# - 如何从 VS 中的 TextBox 获取字符串,然后使用 if 语句将其与整数进行比较?
- javascript - 为什么不等待在 Firefox 上使用异步
- asp.net - 为什么窗口警报不能在任何浏览器中工作
- laravel-backpack - 如何在 laravel 背包中添加按钮