Finally I finished the hard part of my angular 2 application, and i want to see it live on the server.
I have Linux web hosting I'm hosting PHP & SQL websites and I am wondering how I can host the angular 2 app, since I'm running it using npm start
.
Someone told me about Amazon EC2, but i'm not sure how it works since it my first time hosting such application.
I read this: About publishing Angular 2 application and noticed I need to compile my app with JSPM(?) and use it somehow. So I tried to use it. it created jspm_packages
folder in my app root, but I have no idea what it meant to be or how to use it.
- Any help how to publish my app with web hosting or Amazon EC2/Any other way I can allow other people to see and use my app? My app is Angular2 and Laravel as backend.
In fact there are two steps here:
For the second step, the server can be hosted on EC2 for example. But you can notice that you can even host it on Github with gh-pages. I think that this link could help you: https://gist.github.com/chrisjacob/833223. In fact it depends on your need...
If you are referring to elastic beanstalk nodejs ec2, then this answer is best for you, as it took me a while to figure this out, but it turns out to be easier than I thought:
/usr/bin/env: node: No such file or directory
issues, I added the following script.ebextensions/angular2deployment.config
node_modules
&dist
folder if you have, both are not needed.npm install && npm start
(this step must be successful), note that I'm using the angular2's defaultpackage.json
See Angular.IO Deploymentnode_modules
again.ebextensions
is selected as well), and then compress them, do not compress the top folder (you will have subdirectory when deploying which will break the deployment)If you are using MacOS, while compressing, macos will add macos folder which will break the deployment, make sure using a tool that won't add this extra directory, in my case I used
YemuZip
Additional note: EC2 elastic beanstalk will run
npm install
&npm start
, this is why I would recommend running them and make sure that they are fine on your local environment