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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript Introducing JavaScript Let's Make a Game The Language of Programming

Downloading and Running the Project Files

Because of how the Phaser.JS library handles files, you need to be running a web server locally to view a working copy of this project. You can't just open the index.html file in your web browser as you might a basic HTML page. There are several simple ways to get a web server up and running on your computer: I dont see the instruction how to run in Google web server?

6 Answers

Neil McPartlin
Neil McPartlin
14,662 Points

Hi Jose Luis. I'll assume the following...

  • You have already downloaded and unzipped the project files from Treehouse.
  • You have Chrome running.
  • You have followed the blue link provided (Web Server for Chrome) just after the text you copied/pasted above.
  • You clicked 'Add to Chrome' -> 'Add App' in order to add the extension to your Chrome browser.
  • You are now redirected to chrome://apps/

So now...

  • Click on (200 OK!) Web Server. The 'Web Server for Chrome' app opens.
  • Using 'Choose Folder', pick the exact folder within which one will find the relevant index.html file. (By default, it will say 'Web Server : Started').
  • Finally, just click on the URL offered beneath 'Web Server URLs'. Mine happens to be http://127.0.0.1:8887 but yours might be different. A new tab will open in Chrome and your program should be running.
Sheila Anguiano
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sheila Anguiano
Full Stack JavaScript Techdegree Graduate 35,238 Points

Thanks Neil, I was having the same problem...do you know if along the way Treehouse explains why we need a webserver in this course? and the game cannot load locally from the files in our computer?

Neil McPartlin
Neil McPartlin
14,662 Points

Hi Sheila. In the case of this specific course, Jose copy/pasted into his question, the teachers notes where it states.

Because of how the Phaser.JS library handles files, you need to be running a web server locally to view a working copy of this project

It is a statement of fact but it does not try to explain in more detail why this is so.

I have done some of the Full Stack courses on Treehouse and often, they simply start by saying you need to start a 'local server' and suggest some of the ways one can do that, just as they did with this course.

Treehouse teachers often quote the MDN site when providing external references so here is just one link which helps to answer your question.

https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

The specific point of interest is...

The problem with testing local files

Some examples won't run if you open them as local files. This can be due to a variety of reasons, the most likely being:

They feature asynchronous requests. Some browsers (including Chrome) will not run async requests (see Fetching data from the server) if you just run the example from a local file. This is because of security restrictions (for more on web security, read Website security).

They feature a server-side language. Server-side languages (such as PHP or Python) require a special server to interpret the code and deliver the results.

I have been 'playing around with code' for awhile, so previously I would have installed a server called Apache which was quite common. Currently, having studied a bit of node.js and therefore used NPM, I have used packages found in NPM such as 'http-server'. The best local server for you can depend on specifically what code you need to host and on which OS you are developing.

Thanks it works great help!

Best

Jose

Hello Neil thanks again for your information. Do you have a good information of how to install a good web server apache to create my own web site and server at home. The complete info including how to setup a router plus ubuntu web server to practice my techdegree a live? Thanks Again?

Neil McPartlin
Neil McPartlin
14,662 Points

Hi Jose. Wow. That's some shopping list you have there :)

Personally, I wouldn't rush into a dedicated home server too quickly as you will probably need to commandeer an old(er) computer, start by installing Ubuntu as you say, then spend some frustrating hours/days searching for the necessary drivers etc., just to get that up and running.

Take a look at this... https://tutorials.ubuntu.com/tutorial/tutorial-install-ubuntu-desktop#0

As for Apache, it's been around over 20 years and still going I see though their site does look a bit dated. To be fair, these organisations don't charge for their products and services. Here is an article I just Googled from 2 years ago...

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

...it gives you a flavour of how complex this can get.

Here is a video by Alena Holligan at Treehouse where she outlines what you would need to do to install MAMP (My Apache, MySQL and Php) on a Windows machine.

https://teamtreehouse.com/library/setup-your-local-development-environment

https://www.mamp.info/en/

But how are you getting on with using Web Server for Chrome on your own computer? Did you know that you can configure it so that other computers, smartphones and tablets on your home LAN can see it too?

Great Thanks very good information. The google server is very good thanks to you. When I study always think foward and in the future planning to have a internet business at home. I need to learn a lot but I can do it. Thanks for all your information are very good to keep going.

Best Jose

Neil McPartlin
Neil McPartlin
14,662 Points

When I study always think foward and in the future planning to have a internet business at home. I need to learn a lot but I can do it.

Excellent. Great attitude. :)

All I would add is that for local testing, setting up a server on your own local machine in order to be able to test your evolving dev code 'live' would be the most efficient solution. When it comes to going live with your business, it would be best to investigate the countless hosting companies who will charge an appropriate monthly fee but let them take the strain when it comes to...

  • 24/7 uptime
  • Guaranteed sufficient Internet bandwidth
  • Responsibility for ensuring all the latest security patches are added to your 'server' hosted by them.

I wish you every success with your future business.

Thanks Neil excelent.

Hi Jose!

I think that at some point following the Full JavaScript stack you will need also to install Node.js on Ubuntu 16.04:

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

A nice way to go through the LAMP and Node.js stack is by setting up a Virtual Machine with virtualbox. This will avoid the need of an "old(er) computer"

https://www.virtualbox.org/

https://www.turnkeylinux.org/lampstack or https://www.turnkeylinux.org/nodejs

Excellent thanks