0

I am following the tutorial https://github.com/vasansr/pro-mern-stack-2 (to build a CRUD app 'Issue Tracker'). Since i split the app from a single server to separate api and ui servers, I have been having problems getting the ui to load in the browser. Initially i was getting 'unexpected token < in JSON at position 0' in the dev tools console (after creating separate ui and api servers). Then failing to fix this i continued with the chapter hoping more changes might resolve the issue. Now i have completed everything up to and including Ch7 Proxy-Based-Architecture. The ui will still not load in the browser and i'm getting the above (404) error. Everything else appears to be working fine: both servers are running in the terminal and the graphql playground is loading fine.

The code should be fine as i've even gone over it and even copied and pasted from this Git repository just to be double sure. I've also checked the file structure. The only difference is my package.json, as due to dependancy issues i've encountered, some of the package versions are different, so i'm wondering if this could be the problem. But it is unclear to me as i'm getting no issues in the terminal when i run the servers.

This is my ui package.json:

{
  "name": "pro-mern-stack-2-ui",
  "version": "1.0.0",
  "description": "Pro MERN Stack (2nd Edition) - UI",
  "main": "index.js",
  "scripts": {
    "start": "nodemon -w uiserver.js -w .env uiserver.js",
    "compile": "babel src --out-dir public",
    "watch": "babel src --out-dir public --watch --verbose"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/vasansr/pro-mern-stack-2.git"
  },
  "author": "[email protected]",
  "license": "ISC",
  "homepage": "https://github.com/vasansr/pro-mern-stack-2",
  "dependencies": {
    "dotenv": "^6.2.0",
    "express": "^4.16.4",
    "http-proxy-middleware": "^0.21.0",
    "nodemon": "^1.18.9"
  },
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.2.2",
    "@babel/preset-env": "^7.2.3",
    "@babel/preset-react": "^7.0.0"
  }
}

1 Answer 1

2

The problem here was i hadn't compiled my code. I am using babel and had made some changes not realising i needed to recompile my App.js file. As i was trying different things i also got the error:

GET http://localhost:8000/App.js net::ERR_ABORTED 404 (not found)

So i used the command npm run watch in my ui terminal (App.js file is in my user interface directory).

So it seems the problem was i couldn't load the uncompiled file in my browser.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.