在 Netlify 上部署时无法显示来自 app.js 的内容(npm 运行 构建)

Cannot display conent from app.js when deploying on Netlify (npm run build)

当我尝试在 Netlify(npm 运行 构建)上托管时,我无法通过我的 app.js 文件获取内容

这是我的 package.json 文件的样子:

{
  "name": "nasa-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "dotenv": "^8.1.0",
    "jquery": "^1.9.1",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-helmet": "^5.2.1",
    "react-scripts": "0.9.5"
  },
  "devDependencies": {
    "babel-eslint": "^9.0.0",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-wesbos": "0.0.19",
    "eslint-plugin-html": "^5.0.5",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.14.3",
    "eslint-plugin-react-hooks": "^1.7.0",
    "prettier": "^1.18.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "description": "**A Day In The Life On Mars**",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/able-leopard/a-day-in-the-life-on-mars.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/able-leopard/a-day-in-the-life-on-mars/issues"
  },
  "homepage": "https://github.com/able-leopard/a-day-in-the-life-on-mars#readme"
}


看来我不能post截图因为我还是新来的但基本上所有的托管版本节目都是

<div id="root"><div/> 而本地版本实际上显示了我 app.js

中的所有内容

非常感谢!

在您的 package.json 中,您需要将 homepage 更改为 "/"..

这解决了您的问题:https://vigilant-bhabha-b3e068.netlify.com/ (这个 link 不再有效,这只是为了证明我让它适用于 OP - 不是试图劫持他们的部署)

一旦你看到这个请告诉我,我将删除我创建的 Netlify 应用程序和我分叉的 repo..


为了证明这是有效的:

URL:

站点:

{
  ...
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/able-leopard/a-day-in-the-life-on-mars/issues"
  },
  "homepage": "/"
}