我已经创建了一个想要部署到heroku的angular应用程序,但是构建失败了。我已经遵循了https://itnext.io/how-to-deploy-angular-application-to-heroku-1d56e09c5147提供的步骤,但是我没有让它工作。需要进行哪些更改才能使此功能正常工作?
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文件
{
  "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"
  }
}发布于 2019-10-14 02:11:16
您提供的资源为postinstall命令提供了另一种选择。
尝试替换:
"postinstall": "ng build --aot -prod"有了这个:
"heroku-postbuild": "ng build --prod"https://stackoverflow.com/questions/58366366
复制相似问题