D
D
Drovosek012019-05-24 02:37:44
Angular
Drovosek01, 2019-05-24 02:37:44

How to run a compiled Angular2+ application and why does it need a server?

I made a small application on Angular 6.
As I understand it, the whole thing is eventually compiled and assembled into a set of html, css, js and binary files. I googled that there are commands for the Angular CLI that do this, ng bildand ng bild --prodother variations with arguments. First I did the first one, after some time after the experiments - the other one, the dist folder appeared in the root of the project and in it a set of ordinary html, css, js files, etc.
I ran index.html and saw a blank sheet, and an error in Dev Tools

ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///E:/' cannot be created in a document with origin 'null' and URL

I began to google and came across information that in order for the compiled Angular application to work, it needs a server.
Actually questions:
1. How to start the compiled Angular application that it normally worked on the computer? Please provide detailed instructions.
2. If an Angular application really needs a server to run and run, then why? This is a set of ordinary html, css, js files.
3. Is there any way to run an Angular application without a server? If so, which one?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-05-24
@Drovosek01

Try like this https://stackoverflow.com/questions/49622076/secur...

O
OnYourLips, 2019-05-24
@OnYourLips

1. https://angular.io/guide/deployment#basic-deployme...
2. Not needed if you have production mode without SSR.
3. Build the application in production mode without SSR.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question