5

In order to see the ng build result, I need to run ng serve, but how that helps me to create an angular2 project that I can run in any web hosting? my web hosting don't know angular2 or ng serve command. What did I miss in this process?

Please advise how after using angular-cli (which is a great tool) I'm now ready to updload files to any web hosting and see my app running. I thought if I run the "index.html" file I get app that runs and not depeneding on any commands :-/

This is the resuilt of index.html: enter image description here

2 Answers 2

9

ng serve : in memory (local) development ng build : creates a distributable stand-alone app in your dist folder.

So run a ng build and copy the contents of the dist folder to any remote server and it should run (need to run it in the root btw, if you want to run your app in a subfolder on your remote server, do a ng build --base-href myapp --prod)

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

6 Comments

How it runs if it can't find the files
Where on the server are the contents of the dist folder? Is in in a subfolder?
In other words, what is the URL you use to request the index.html file? Exactly?
it worked. I just needed to change the <base href="./"> url
I am facing the similar issue but i was not able to resolve the issue as per recommended above
|
1

If you want to run it directly from the dist folder

ng build --base-href .

The dot "." in the end will help you run it locally.

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.