首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我的angular应用程序无法部署到heroku。我该如何解决这个问题?

我的angular应用程序无法部署到heroku。我该如何解决这个问题?
EN

Stack Overflow用户
提问于 2019-10-14 02:04:46
回答 1查看 689关注 0票数 0

我已经创建了一个想要部署到heroku的angular应用程序,但是构建失败了。我已经遵循了https://itnext.io/how-to-deploy-angular-application-to-heroku-1d56e09c5147提供的步骤,但是我没有让它工作。需要进行哪些更改才能使此功能正常工作?

代码语言:javascript
运行
复制
Here's my build log

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  v10.16.3
       engines.npm (package.json):   6.9.0

       Resolving node version v10.16.3...
       Downloading and installing node 10.16.3...
       npm 6.9.0 already installed with node

-----> Restoring cache
       - node_modules

-----> Installing dependencies
       Installing node modules (package.json + package-lock)

       > core-js@2.6.9 postinstall /tmp/build_4cf23a391f9c002e9d1c85d30acc96ae/node_modules/babel-runtime/node_modules/core-js
       > node scripts/postinstall || echo "ignore"


       > core-js@3.2.1 postinstall /tmp/build_4cf23a391f9c002e9d1c85d30acc96ae/node_modules/core-js
       > node scripts/postinstall || echo "ignore"


       > core-js@2.6.9 postinstall /tmp/build_4cf23a391f9c002e9d1c85d30acc96ae/node_modules/karma/node_modules/core-js
       > node scripts/postinstall || echo "ignore"


       > @angular/cli@8.3.9 postinstall /tmp/build_4cf23a391f9c002e9d1c85d30acc96ae/node_modules/@angular/cli
       > node ./bin/postinstall/script.js


       > bjornlidenfix@0.0.0 postinstall /tmp/build_4cf23a391f9c002e9d1c85d30acc96ae
       > ng build --aot -prod

       Unknown option: '-d'
       npm ERR! code ELIFECYCLE
       npm ERR! errno 1
       npm ERR! bjornlidenfix@0.0.0 postinstall: `ng build --aot -prod`
       npm ERR! Exit status 1
       npm ERR! 
       npm ERR! Failed at the bjornlidenfix@0.0.0 postinstall script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.00JQ7/_logs/2019-10-13T16_59_55_855Z-debug.log
-----> Build failed

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

这是我的package.json文件

代码语言:javascript
运行
复制
{
  "name": "bjornliden",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node server.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ng build --aot -prod"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.9",
    "@angular/cli": "~8.3.9",
    "@angular/common": "~8.2.9",
    "@angular/compiler": "~8.2.9",
    "@angular/compiler-cli": "~8.2.9",
    "@angular/core": "~8.2.9",
    "@angular/forms": "~8.2.9",
    "@angular/platform-browser": "~8.2.9",
    "@angular/platform-browser-dynamic": "~8.2.9",
    "@angular/router": "~8.2.9",
    "contentful": "^7.10.0",
    "express": "^4.17.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "typescript": "~3.5.3",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.9",
    "@angular/language-service": "~8.2.9",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0"
  },
  "engines": {
    "node": "v10.16.3",
    "npm": "6.9.0"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2019-10-14 02:11:16

您提供的资源为postinstall命令提供了另一种选择。

尝试替换:

代码语言:javascript
运行
复制
"postinstall": "ng build --aot -prod"

有了这个:

代码语言:javascript
运行
复制
"heroku-postbuild": "ng build --prod"
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58366366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档