able-leopard
able-leopard

Reputation: 115

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

I am having trouble getting content to come through in my app.js file when I try to host on Netlify (npm run build)

Here is what my package.json file looks like:

{
  "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"
}


It seems like I can't post screenshots because I am still new here but basically all the hosted version shows is

<div id="root"><div/> while the local version actually displays all the contents in my app.js

Thanks so much in advance!

Upvotes: 1

Views: 128

Answers (1)

Matt Oestreich
Matt Oestreich

Reputation: 8538

In your package.json you need to change your homepage to "/"..

This resolved your issue: https://vigilant-bhabha-b3e068.netlify.com/ (This link no longer works, this was only to demonstrate that I got it working for OP - not trying to hijack their deployment)

Let me know once you see this and I will remove the Netlify app I created and the repo I forked..


In order to demonstrate that this is working:

URL: enter image description here

SITE: enter image description here

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

Upvotes: 1

Related Questions