Display Angular 4 in Linux Web Hosting

0

in my Web Hosting Linux has 512 of RAM and therefore the ng build could not be completed so I resorted to transfer the / dist (locally generated) to the hosting and when I tried to run it with node it does not work.

This is my server.js code

const express = require('express');
const app = express();

app.use(express.static(__dirname + "/dist"));
app.use('/*',function(req, res) {
    res.sendfile(__dirname + '/dist/index.html');
});

app.listen(process.env.PORT || 8080);

and in package.json

{
  "name": "admin-school",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ng build --aot -prod",
    "start": "node server.js"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/cli": "1.4.3",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "express": "^4.16.2",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14",
    "typescript": "~2.3.3"
  },
  "devDependencies": {
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2"
  }, 
  "engines": {
    "node": "6.11.3",
    "npm": "3.10.10"
  }
}

Versions installed on my Linux Web Hosting

node v6.11.3

express 4.16.2

    
asked by Yuichi Muñoz 09.03.2018 в 03:54
source

0 answers