Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Garrett Hughes
Garrett Hughes
Python Development Techdegree Student 32,971 Points

Getting http-server to look in the correct folders

I'm just trying to build a react hello world app but can't seem to get it to work.

I cd to the correct directory then run 'http-server -p 3000' but it won't render the react element correctly. In dev tools it says "unexpected token '<' on line 2'. There's not a '<' anywhere in my app.js file so I'm guessing it's not looking in the correct directory.

I installed http-server globally, but like I said, I navigated to the directory that the files I'm working on are in.

This is all I've got in the directory;

React-ChessClock (directory)
<!--index.html file-->
 <!DOCTYPE html>
 <html lang="en">

     <meta charset="UTF-8">
     <meta name="description" content="DESCRIPTION">
     <!-- <link rel="stylesheet" href="PATH"> -->

    <div id="root">Loading...</div>
  <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
  <script src="app.js"></script>
//app.js file
const header = React.createElement(
  "Hello React!"


Anyone got any advice? lol

3 Answers

Garrett Hughes
Garrett Hughes
Python Development Techdegree Student 32,971 Points

Dangit. Tried to change it to a component and now it's back to the 'unexpected token <' error.

function Header() {
  return (

  <Header />,

Is my syntax incorrect somewhere?