Angular App - Heroku部署

时间:2017-07-21 07:37:28

标签: angular heroku

上次我设法使用本指南Angular CLI Deployment: Host Your Angular 2 App on Heroku

部署我的应用

但是今天我试图部署另一个,我获得了成功,但

  

ng build

是记录运行或执行。

我的package.json



{
  "name": "management",
  "version": "1.0.0",
  "engines": {
    "node": "6.11.0"
  },
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "start": "node server.js",
    "postinstall": "ng build --aot -prod"
  },
  "private": true,
  "dependencies": {
    "@angular/compiler": "^4.0.0",
    "@angular/cli": "1.2.0",
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "express": "^4.15.3",
    "mydatepicker": "^2.0.21",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.1",
    "firebase": "^4.1.3",
    "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",
    "mydatepicker": "^2.0.22",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}




构建日志



-----> Node.js app detected
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 6.x via semver.io...
       Downloading and installing node 6.11.1...
       Using default npm version: 3.10.10
-----> Restoring cache
       Skipping cache restore (new-signature)
-----> Building dependencies
       Installing node modules (package.json)
       project-mngment-app@0.0.0 /tmp/build_227ca2ee7a02142343394d7a791c62f6
       ├─┬ @angular/animations@4.3.1
       │ └── tslib@1.7.1
       ├── @angular/common@4.3.1
       ├── @angular/compiler@4.3.1
       ├── @angular/core@4.3.1
       ├── @angular/forms@4.3.1
       ├── @angular/http@4.3.1
       ├── @angular/platform-browser@4.3.1
       ├── @angular/platform-browser-dynamic@4.3.1
       ├── @angular/router@4.3.1
       ├── core-js@2.4.1
       ├─┬ rxjs@5.4.2
       │ └── symbol-observable@1.0.4
       └── zone.js@0.8.14
       
-----> Caching build
       Clearing previous node cache
       Saving 2 cacheDirectories (default):
       - node_modules
       - bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 23.1M
-----> Launching...
       Released v3
       https://stormy-beach-92848.herokuapp.com/ deployed to Heroku




1 个答案:

答案 0 :(得分:1)

在尝试将Angular + Express项目部署到Heroku时,我遇到了类似的问题。

从package.json的外观来看,你缺少一个预构建脚本,它将在Heroku服务器上安装Angular-cli,以便它可以运行NG命令。

尝试添加"预安装":" npm install -g @ angular / cli"到"脚本"



"scripts": {
    "ng": "ng",
    "start": "ng build && node app.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "preinstall": "npm install -g @angular/cli",
    "postinstall": "ng build --prod"
  }




我刚刚创建了一个已经为Heroku部署配置的Angular + Express入门回购。请随意尝试一下,让我知道!

https://github.com/pabloruiz55/Angular-Express-Heroku