首页 > 解决方案 > 在反应应用程序中向 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.

有没有人遇到过这个问题?

标签: reactjsbuild

解决方案


该消息不是错误。运行npm run build命令后,应该会出现一个名为 build 的文件夹,其中包含您的 react 应用程序。您需要将该文件夹的内容上传到 cpanel 文件管理器中的 public_html 文件夹。(确保您上传的是构建文件夹中的内容,而不是构建文件夹本身)。这是一个简短教程的链接


推荐阅读