【问题标题】:Unable to deploy React project using XAMPP无法使用 XAMPP 部署 React 项目
【发布时间】:2020-05-30 13:53:27
【问题描述】:

如何构建我的项目,以便可以将它放在任何我想要的地方?例如,如果可能的话,我很想在 XAMPP?

上看到它

每当我构建我的 react 应用程序时,index.html 都是空的。

这里是 GitHub 上的整个项目:https://github.com/slabys/reacty.git

每当我使用npm run build 时,我的文件夹 build 都会创建包含所有内容:

index.html 来自构建:https://pastebin.com/WSyAvrwu

package.json

    {
  "name": "my_react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@stardust-ui/docs-components": "^0.40.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "bootstrap": "^4.5.0",
    "browser-sync": "^2.26.7",
    "del": "^5.1.0",
    "express": "^4.17.1",
    "express-favicon": "^2.0.1",
    "gulp-autoprefixer": "^7.0.1",
    "gulp-concat": "^2.6.1",
    "gulp-copy": "^4.0.1",
    "gulp-data": "^1.3.1",
    "gulp-plumber": "^1.2.1",
    "gulp-sourcemaps": "^2.6.5",
    "gulp-twig": "^1.2.0",
    "prettier": "^1.4.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1",
    "react-sidebar": "^3.0.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "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"
    ]
  },
  "description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
  "main": "index.js",
  "devDependencies": {
    "@craco/craco": "^5.6.4",
    "@semantic-ui-react/craco-less": "^1.2.1",
    "gulp": "^4.0.2",
    "gulp-sass": "^4.1.0",
    "node-sass": "^4.14.1",
    "semantic-ui-less": "^2.4.1"
  },
  "author": "slabys",
  "license": "ISC",
  "repository": {
    "type": "git",
    "url": "react"
  },
  "optionalDependencies": {}
}

【问题讨论】:

  • 您可以使用 xampp 或任何其他 Web 服务器部署 React 应用程序。检查deploymentthis answer
  • 是的 index.html 并不完全是空的,但它仍然没有包含我所做的所有事情......基本上它唯一的白页。因此,如果我要使用“build”文件夹并将其移动到 XAMPP htdocs 中,我将看到的只是白页。

标签: reactjs deployment xampp


【解决方案1】:

问题解决了!

一切正常。就在我在 XAMPP htdocs 中有这个项目build 时,我将其放入了一个文件夹中。因此,从文件夹 直接在 localhost 下移动文件后,一切都开始工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-24
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    相关资源
    最近更新 更多