3

I have created a new angular app using this command:

ng new angularapp

after that, I have used this command to generate a dist folder.

ng build --prod

after that, I tried to open the index.html file in dist folder but I am getting this error:

enter image description here

1 Answers1

3

You need to have a running http server to view the application once it's build

If you just wan't to view the application in your local browser you could run a server using tools like VS code extention Live Server

You could also install run and run local apache server and place the files in the root folder and visit localhost using tools like Wamp , Xamp or Lamp.

OR

You can do that using http-server npm package.

Step 1 : First install the package globally

npm install http-server -g.

Step 2 :Then inside your project directory(in the terminal) just run

http-server dist/.

And if your are using angular 6.x.x, You have to run

http-server dist/your-project-name

Now you can visit http://localhost:8080 to view your application

Joel Joseph
  • 5,889
  • 4
  • 31
  • 36