Angular应用程序不基于Heroku构建

Angular应用程序不基于Heroku构建,heroku,angular-cli,Heroku,Angular Cli,我有一个angular 2应用程序,可以在我的MAC电脑上正常运行。以下是相关版本: @angular/cli: 1.0.0-beta.30 node: 7.6.0 os: darwin x64 @angular/cli: 1.0.0-beta.30 @angular/common: 2.4.9 @angular/compiler-cli: 2.4.9 @angular/compiler: 2.4.9 @angular/core: 2.4.9 @angular/forms: 2.4.9 @ang

我有一个angular 2应用程序,可以在我的MAC电脑上正常运行。以下是相关版本:

@angular/cli: 1.0.0-beta.30
node: 7.6.0
os: darwin x64
@angular/cli: 1.0.0-beta.30
@angular/common: 2.4.9
@angular/compiler-cli: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
今天我创建了一个heroku应用程序,我一直在尝试使用heroku CLI在其上部署该应用程序。我已经按照步骤这样做了

虽然它在我的MAC上可以正确编译,但在heroku上它会出现许多错误,其中最常见的错误如下:

ERROR in /tmp/build_56020fc9198e03c2d2338a818aaf8e5d/src/$$_gendir/app/admin/configuration/email-templates/email-template-form/email-template-form.component.ngfactory.ts (589,18): Property 'loadingOverlay' is private and only accessible within class 'BaseComponent'.
以下是my
package.json中的包版本:

"dependencies": {
    "@angular/cli": "1.0.0-beta.30",
    "@angular/common": "2.4.9",
    "@angular/compiler-cli": "2.4.9",
    "@angular/compiler": "2.4.9",
    "@angular/core": "2.4.9",
    "@angular/forms": "2.4.9",
    "@angular/http": "2.4.9",
    "@angular/platform-browser": "2.4.9",
    "@angular/platform-browser-dynamic": "2.4.9",
    "@angular/router": "3.4.9",
    "@types/jquery": "^2.0.40",
    "@types/node": "^6.0.62",
    "rxjs": "^5.0.1",
    "typescript": "2.0.10"
  },
  "devDependencies": {
      "@angular/cli": "1.0.0-beta.30",
      "@angular/compiler-cli": "2.4.9",
      "@types/jasmine": "2.5.38",
      "@types/jquery": "^2.0.40",
      "@types/node": "^6.0.42",
      "typescript": "2.0.10"
  }

还有更多,但我只列出了相关的内容。

我终于找到了解决方案。Heroku缓存所有的NPM包(对Bower也是如此)

如果您在更改包.json中的版本后部署应用程序,heroku不会下载新版本,而是使用缓存的版本

要强制Heroku下载包而不是使用缓存的包,请执行以下操作:

$ heroku config:set NODE_MODULES_CACHE=false
$ git commit -am 'disable node_modules cache' --allow-empty
$ git push heroku master
您可以在成功推送后取消设置if,否则,每次推送后,它将下载package.json中列出的所有包

$heroku config:set NODE_MODULES_CACHE=true

尝试升级您的angular cli版本。以前通过升级解决了类似的问题。这就是我最终要做的。我删除了
节点\u模块
,然后再次运行
npm安装
。它更新了我的所有软件包,我得到了与
Heroku
相同的错误。然后我修复了所有这些问题并部署了它。它成功了。但是如果您看到我的
package.json
,我为angular软件包提供的版本是精确的(不是^or),因此我不明白为什么
Heroku
使用不同的版本构建它。