3

Hello I am following this tutorial from the AngularJS documentation.

I am trying to use this approach for learning this.

You will need an http server running on your system. Mac and Linux machines typically have Apache pre-installed, but If you don't already have one installed, you can use node to run scripts/web-server.js, a simple bundled http server.

My server is started but the only things that happens on localhost:8000 (the port its running on) is that files get listed.

How do I deploy with Node.js?

When I navigate to localhost:8000 in my browser, this is my server log.

112-108-15:scripts phe$ ./web-server.js
Http Server running at http://localhost:8000/
GET / Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36
GET / Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36

3 Answers 3

5

As you can see the instruction, you need to run

node ./scripts/web-server.js

and go to http://localhost:8000/app/index.html.

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

Comments

2

If you have node installed, go to the directory where your angular application is and type:

scripts/webserver.js

hit enter and voila!

You can visit your site at:

http://localhost:8000/

If you don't have node installed, install node and then go to the first step.

5 Comments

I have done this. And got the server started. What url should i use? I am trying localhost:8000
What happens when you go to that url?
You're running the command from the wrong directory (the scripts directory). Go up one directory cd .. and then type scripts/web-server.js
Now all the folders in angular-phonecat is listed instead.
so go to localhost:8000/app/index.html
1

You need to serve the files from a server on your local machine.

In the docs, it is mentioned you can serve the files from a node server.

However, if you do not want to download and run nodejs, and you are on Mac/Linux you have python already installed, you can also cd into the directory with index.html and run a python server - python -m SimpleHTTPServer 8000. This will serve the files on port 8000. Go to localhost:8000 and you will see your files being rendered.

And, if you want to deploy it to production on a remote machine, I came across deployment of nodejs & angular application deployment to production using ansible. I used the same to deploy my first app to production.

1 Comment

are you "the" Elon Musk who owns Tesla?

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.