Tuesday 16 May 2017

Angular 4 + Express not starting on Heroku

Im trying to deploy my angular 4 application to heroku but I get errors like it cant find "ng command" and such. Im gussing I need to change something in the package.json to force it to install CLI but I cant get it to work.

Here is the package.json:

{
  "name": "q",
  "version": "0.0.0",
  "license": "MIT",
  "watch": {
    "run-watch": {
      "patterns": [
        "src",
        "server",
        "e2e"
      ],
      "extensions": "js,ts,css,scss,html"
    }
  },
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build && node server/server.js",
    "run-watch": "ng build && node server/server.js",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "watch": "npm-watch"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.2",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.4",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "axios": "^0.16.1",
    "body-parser": "^1.17.1",
    "core-js": "^2.4.1",
    "express": "^4.15.2",
    "hammerjs": "^2.0.8",
    "morgan": "^1.8.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.5.2",
    "npm-watch": "^0.1.9",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

and here is the message I get during npm start:

npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! q@0.0.0 start: `ng serve`
npm ERR! spawn ENOENT

How can I make the cli work on the server?



via Jedi Schmedi

No comments:

Post a Comment