Publish Angular 2 Application (Deployment)

Finally, I finished the tough part of my angular 2 application, and I want to see it live on the server.

I have Linux web hosting. I host PHP and SQL websites, and I am wondering how I can host an angular 2 application, since I run it with npm start.

Someone told me about Amazon EC2, but I'm not sure how this has been working since I first hosted such an application.

I read this: About publishing angular 2 applications and noticed that I need to compile my application with JSPM (?) And use it somehow. So I tried to use it. He created a folder jspm_packagesat the root of my application, but I have no idea what this means and how to use it.

  • Any help on publishing my application using web hosting or Amazon EC2 / Any other way to let other people see and use my application? My app is Angular2 and Laravel as a backend.
+2
source share
2 answers

In fact, there are two steps:

, , EC2. , Github gh-. , : https://gist.github.com/chrisjacob/833223. ...

+3

beanstalk nodejs ec2, , , , , , :

  • , , /usr/bin/env: node: No such file or directory, script

.ebextensions/angular2deployment.config

files:
  "/opt/elasticbeanstalk/env.vars" :
    mode: "000775"
    owner: root
    group: users
    content: |
      export NPM_CONFIG_LOGLEVEL=error
      export NODE_PATH=`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
  "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh" :
    mode: "000775"
    owner: root
    group: users
    content: |
      #!/bin/bash
      . /opt/elasticbeanstalk/env.vars
      function error_exit
      {
        eventHelper.py --msg "$1" --severity ERROR
        exit $2
      }

      #install not-installed yet app node_modules
      if [ ! -d "/var/node_modules" ]; then
        mkdir /var/node_modules ;
      fi
      if [ -d /tmp/deployment/application ]; then
        ln -s /var/node_modules /tmp/deployment/application/
      fi

      OUT=$([ -d "/tmp/deployment/application" ] && cd /tmp/deployment/application && $NODE_PATH/node $NODE_PATH/npm install 2>&1) || error_exit "Failed to run npm install.  $OUT" $?
      echo $OUT
  "/opt/elasticbeanstalk/hooks/configdeploy/pre/50npm.sh" :
    mode: "000666"
    owner: root
    group: users
    content: |
       #no need to run npm install during configdeploy
  1. node_modules dist, , .
  2. npm install && npm start ( ), , angular2 default package.json . Angular.IO Deployment
  3. # 3 , node_modules
  4. (, .ebextensions), , ( , )
  5. !

MacOS , macos macos, , , , , YemuZip

: beanstalk EC2 npm install npm start, ,

0

Source: https://habr.com/ru/post/1655639/


All Articles