5

I am started with AngularJS 2:

  • Instaled NodeJS
  • Downloaded start project
  • Run on Node

All works!

However how to run it in production on shared hosting (without Node ant not on vps)? How to open in browser by clicking on index.html?

AndersonDev
  • 83
  • 1
  • 1
  • 8
  • 1
    hi, did you find the answer. same problem here – funky-nd Jun 19 '16 at 16:50
  • 1
    Yes, [here](https://github.com/AngularClass/angular2-webpack-starter) . You need to build your app for runing in host. – AndersonDev Jun 20 '16 at 19:47
  • Possible duplicate of [How to deploy a simple Angular2 app on a shared hosting?](https://stackoverflow.com/questions/40854368/how-to-deploy-a-simple-angular2-app-on-a-shared-hosting) – Samar Gurjar Jun 06 '18 at 10:58

2 Answers2

13

You have to command ng build --prod.

This will build your app into the dist folder.
Copy the contents of your dist folder to the public directory of your shared hosting.

Answered here: https://stackoverflow.com/a/40854458/2816279

Community
  • 1
  • 1
Pedro Ferreira
  • 493
  • 7
  • 14
  • 1
    Works great, if Angular 2 CLI was used, otherwise it returns `You have to be inside an angular-cli project in order to use the build command.`. Any recommendation on how to build a non CLI Angular project? – Kristjan O. Mar 02 '17 at 00:27
  • @Kristjan O. are you in the same boat as the OP where you based a project on a starter project and now can't build it? Where did you download your starter project? If it was the Angular Class starter project use: `npm build:aot:prod`. Check the `project.json` file for any build commands. Maybe query on the project page for the starter project you downloaded. – Martin Jun 28 '17 at 12:30
2

You dont need anything else other than importing a few javascript files in your index.html file.

Check this live example

Download it from plunkr here and extract it to your required folder in your shared hosting, that's all.

Source: https://angular.io/docs/js/latest/quickstart.html

user1685442
  • 161
  • 2
  • 5