Почему не запускается приложение на Heroku? На localhost: 3000 всё работает. Я так понимаю проблема с роутингом а как исправить?
packege.json
{
"name": "app-shop",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng build && node server/server.js",
"serve": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/cli": "~10.1.2",
"@angular/compiler-cli": "~10.1.2",
"@agm/core": "^3.0.0-beta.0",
"@angular/animations": "~10.1.2",
"@angular/common": "^10.1.6",
"@angular/compiler": "~10.1.2",
"@angular/core": "~10.1.2",
"@angular/fire": "^6.1.3",
"@angular/forms": "~10.1.2",
"@angular/platform-browser": "~10.1.2",
"@angular/platform-browser-dynamic": "~10.1.2",
"@angular/router": "~10.1.2",
"angular-common": "^0.1.0",
"angular2-pipes": "^2.0.1",
"angular2-yandex-maps": "^1.0.42",
"compression": "^1.7.4",
"express": "^4.17.1",
"firebase": "^8.1.1",
"moment": "^2.29.1",
"ngx-pagination": "^5.0.0",
"ngx-pipes": "^2.7.5",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.6.3",
"tslib": "^2.0.0",
"zone.js": "~0.10.2",
"typescript": "~4.0.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.2",
"@angular/cli": "~10.1.2",
"@angular/compiler-cli": "~10.1.2",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
},
"engines": {
"node": "12.18.3",
"npm": "6.14.6"
}
}
server/server.js
const path = require('path');
const express = require('express');
const app = express();
const srcPath = path.join(__dirname, '..', 'dist/app-shop');
const port = process.env.PORT || 3000;
app.use(express.static(srcPath));
app.get('*', (req, res) => {
res.sendFile(path.join(srcPath, 'index.html'))
});
app.listen(port, () => {
console.log("SERVER WORKS!!!")
})
сборка
-----> 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): 12.18.3
engines.npm (package.json): 6.14.6
Resolving node version 12.18.3...
Downloading and installing node 12.18.3...
npm 6.14.6 already installed with node
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules
> [email protected] install /tmp/build_0a046804/node_modules/webpack-dev-server/node_modules/fsevents
> node install.js
Skipping 'fsevents' build as platform linux is not supported
> [email protected] install /tmp/build_0a046804/node_modules/watchpack-chokidar2/node_modules/fsevents
> node install.js
Skipping 'fsevents' build as platform linux is not supported
> [email protected] postinstall /tmp/build_0a046804/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_0a046804/node_modules/@firebase/polyfill/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_0a046804/node_modules/protobufjs
> node scripts/postinstall
> @angular/[email protected] postinstall /tmp/build_0a046804/node_modules/@angular/cli
> node ./bin/postinstall/script.js
added 1593 packages in 45.652s
-----> Build
Running build
> [email protected] build /tmp/build_0a046804
> ng build
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling ngx-pagination : module as esm5
Compiling @angular/fire : es2015 as esm2015
Compiling @angular/fire/auth : es2015 as esm2015
Compiling @angular/fire/database : es2015 as esm2015
WARNING in /tmp/build_0a046804/src/app/repository/goods.repository.ts depends on 'rxjs/Observable'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
WARNING in /tmp/build_0a046804/src/app/repository/goods.repository.ts depends on 'rxjs/add/observable/from'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
chunk {cart-cart-module} cart-cart-module.js, cart-cart-module.js.map (cart-cart-module) 45.2 kB [rendered]
chunk {contact-contact-module} contact-contact-module.js, contact-contact-module.js.map (contact-contact-module) 14 kB [rendered]
chunk {default~cart-cart-module~goods-goods-module~question-question-module~wholesale-wholesale-module} default~cart-cart-module~goods-goods-module~question-question-module~wholesale-wholesale-module.js, default~cart-cart-module~goods-goods-module~question-question-module~wholesale-wholesale-module.js.map (default~cart-cart-module~goods-goods-module~question-question-module~wholesale-wholesale-module) 283 kB [rendered]
chunk {default~goods-goods-module~question-question-module} default~goods-goods-module~question-question-module.js, default~goods-goods-module~question-question-module.js.map (default~goods-goods-module~question-question-module) 836 kB [rendered]
chunk {firebase-auth} firebase-auth.js, firebase-auth.js.map (firebase-auth) 181 kB [rendered]
chunk {goods-goods-module} goods-goods-module.js, goods-goods-module.js.map (goods-goods-module) 167 kB [rendered]
chunk {main} main.js, main.js.map (main) 122 kB [initial] [rendered]
chunk {payment-payment-module} payment-payment-module.js, payment-payment-module.js.map (payment-payment-module) 23.8 kB [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 141 kB [initial] [rendered]
chunk {question-question-module} question-question-module.js, question-question-module.js.map (question-question-module) 55.9 kB [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 9.62 kB [entry] [rendered]
chunk {stock-stock-module} stock-stock-module.js, stock-stock-module.js.map (stock-stock-module) 5.2 kB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 17.8 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 2.63 MB [initial] [rendered]
chunk {wholesale-wholesale-module} wholesale-wholesale-module.js, wholesale-wholesale-module.js.map (wholesale-wholesale-module) 30.6 kB [rendered]
Date: 2020-12-12T13:23:19.579Z - Hash: d267ffcda83c7756c352 - Time: 38744ms
-----> Caching build
- node_modules
-----> Pruning devDependencies
removed 1074 packages and audited 520 packages in 15.905s
31 packages are looking for funding
run `npm fund` for details
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build succeeded!
-----> Discovering process types
~ Mis-cased procfile detected; ignoring.
~ Rename it to Procfile to have it honored.
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 103.5M
-----> Launching...
Released v5
https://app-shop-product.herokuapp.com/ deployed to Heroku
ошибки
$ heroku logs --tail
2020-12-12T11:34:26.760805+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/architect-command.js
2020-12-12T11:34:26.760805+00:00 app[web.1]: - /app/node_modules/@angular/cli/commands/build-impl.js
2020-12-12T11:34:26.760806+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/export-ref.js
2020-12-12T11:34:26.760806+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/index.js
2020-12-12T11:34:26.760807+00:00 app[web.1]: - /app/node_modules/@angular/cli/utilities/json-schema.js
2020-12-12T11:34:26.760807+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/command-runner.js
2020-12-12T11:34:26.760807+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/cli/index.js
2020-12-12T11:34:26.760808+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/init.js
2020-12-12T11:34:26.760809+00:00 app[web.1]: - /app/node_modules/@angular/cli/bin/ng
2020-12-12T11:34:26.761380+00:00 app[web.1]: See "/tmp/ng-gE3aEK/angular-errors.log" for further details.
2020-12-12T11:34:26.769934+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-12-12T11:34:26.770183+00:00 app[web.1]: npm ERR! syscall spawn
2020-12-12T11:34:26.770308+00:00 app[web.1]: npm ERR! file sh
2020-12-12T11:34:26.770465+00:00 app[web.1]: npm ERR! errno ENOENT
2020-12-12T11:34:26.772750+00:00 app[web.1]: npm ERR! [email protected] start: `ng build && node server/server.js`
2020-12-12T11:34:26.772885+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-12-12T11:34:26.773066+00:00 app[web.1]: npm ERR!
2020-12-12T11:34:26.773207+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2020-12-12T11:34:26.773333+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-12-12T11:34:26.813695+00:00 app[web.1]:
2020-12-12T11:34:26.813878+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-12-12T11:34:26.814047+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-12-12T11_34_26_774Z-debug.log
2020-12-12T11:34:26.880437+00:00 heroku[web.1]: Process exited with status 1
2020-12-12T11:34:26.917144+00:00 heroku[web.1]: State changed from starting to crashed
2020-12-12T13:01:37.000000+00:00 app[api]: Build started by user [email protected]
2020-12-12T13:03:31.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/0f40f12b-b5c6-46c1-a830-0114200fc6c9/activity/builds/78840df5-d624-4b6a-aa79-86a4644db4da
2020-12-12T13:21:38.000000+00:00 app[api]: Build started by user [email protected]
2020-12-12T13:24:11.081607+00:00 app[api]: Deploy f780c118 by user [email protected]
2020-12-12T13:24:11.081607+00:00 app[api]: Release v5 created by user [email protected]
2020-12-12T13:24:11.261856+00:00 heroku[web.1]: State changed from crashed to starting
2020-12-12T13:24:24.458688+00:00 heroku[web.1]: Starting process with command `npm start`
2020-12-12T13:24:27.123842+00:00 app[web.1]:
2020-12-12T13:24:27.123859+00:00 app[web.1]: > [email protected] start /app
2020-12-12T13:24:27.123860+00:00 app[web.1]: > ng build && node server/server.js
2020-12-12T13:24:27.123865+00:00 app[web.1]:
2020-12-12T13:24:28.308221+00:00 app[web.1]: An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
2020-12-12T13:24:28.308281+00:00 app[web.1]: Require stack:
2020-12-12T13:24:28.308282+00:00 app[web.1]: - /app/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
2020-12-12T13:24:28.308283+00:00 app[web.1]: - /app/node_modules/@angular-devkit/architect/node/index.js
2020-12-12T13:24:28.308284+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/architect-command.js
2020-12-12T13:24:28.308284+00:00 app[web.1]: - /app/node_modules/@angular/cli/commands/build-impl.js
2020-12-12T13:24:28.308285+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/export-ref.js
2020-12-12T13:24:28.308285+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/index.js
2020-12-12T13:24:28.308286+00:00 app[web.1]: - /app/node_modules/@angular/cli/utilities/json-schema.js
2020-12-12T13:24:28.308286+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/command-runner.js
2020-12-12T13:24:28.308286+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/cli/index.js
2020-12-12T13:24:28.308287+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/init.js
2020-12-12T13:24:28.308287+00:00 app[web.1]: - /app/node_modules/@angular/cli/bin/ng
2020-12-12T13:24:28.308776+00:00 app[web.1]: See "/tmp/ng-FOvfBf/angular-errors.log" for further details.
2020-12-12T13:24:28.318909+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-12-12T13:24:28.319188+00:00 app[web.1]: npm ERR! syscall spawn
2020-12-12T13:24:28.319409+00:00 app[web.1]: npm ERR! file sh
2020-12-12T13:24:28.319665+00:00 app[web.1]: npm ERR! errno ENOENT
2020-12-12T13:24:28.322102+00:00 app[web.1]: npm ERR! [email protected] start: `ng build && node server/server.js`
2020-12-12T13:24:28.322239+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-12-12T13:24:28.322395+00:00 app[web.1]: npm ERR!
2020-12-12T13:24:28.322539+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2020-12-12T13:24:28.322671+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-12-12T13:24:28.331544+00:00 app[web.1]:
2020-12-12T13:24:28.331708+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-12-12T13:24:28.331796+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-12-12T13_24_28_324Z-debug.log
2020-12-12T13:24:28.391602+00:00 heroku[web.1]: Process exited with status 1
2020-12-12T13:24:28.441446+00:00 heroku[web.1]: State changed from starting to crashed
2020-12-12T13:24:28.444839+00:00 heroku[web.1]: State changed from crashed to starting
2020-12-12T13:24:38.248812+00:00 heroku[web.1]: Starting process with command `npm start`
2020-12-12T13:24:40.000000+00:00 app[api]: Build succeeded
2020-12-12T13:24:40.479995+00:00 app[web.1]:
2020-12-12T13:24:40.480006+00:00 app[web.1]: > [email protected] start /app
2020-12-12T13:24:40.480007+00:00 app[web.1]: > ng build && node server/server.js
2020-12-12T13:24:40.480007+00:00 app[web.1]:
2020-12-12T13:24:42.037402+00:00 app[web.1]: An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
2020-12-12T13:24:42.037439+00:00 app[web.1]: Require stack:
2020-12-12T13:24:42.037441+00:00 app[web.1]: - /app/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
2020-12-12T13:24:42.037442+00:00 app[web.1]: - /app/node_modules/@angular-devkit/architect/node/index.js
2020-12-12T13:24:42.037442+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/architect-command.js
2020-12-12T13:24:42.037442+00:00 app[web.1]: - /app/node_modules/@angular/cli/commands/build-impl.js
2020-12-12T13:24:42.037445+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/export-ref.js
2020-12-12T13:24:42.037445+00:00 app[web.1]: - /app/node_modules/@angular-devkit/schematics/tools/index.js
2020-12-12T13:24:42.037445+00:00 app[web.1]: - /app/node_modules/@angular/cli/utilities/json-schema.js
2020-12-12T13:24:42.037446+00:00 app[web.1]: - /app/node_modules/@angular/cli/models/command-runner.js
2020-12-12T13:24:42.037446+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/cli/index.js
2020-12-12T13:24:42.037447+00:00 app[web.1]: - /app/node_modules/@angular/cli/lib/init.js
2020-12-12T13:24:42.037447+00:00 app[web.1]: - /app/node_modules/@angular/cli/bin/ng
2020-12-12T13:24:42.038255+00:00 app[web.1]: See "/tmp/ng-V3Hq4Q/angular-errors.log" for further details.
2020-12-12T13:24:42.049373+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-12-12T13:24:42.049580+00:00 app[web.1]: npm ERR! syscall spawn
2020-12-12T13:24:42.049730+00:00 app[web.1]: npm ERR! file sh
2020-12-12T13:24:42.049882+00:00 app[web.1]: npm ERR! errno ENOENT
2020-12-12T13:24:42.052170+00:00 app[web.1]: npm ERR! [email protected] start: `ng build && node server/server.js`
2020-12-12T13:24:42.052250+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-12-12T13:24:42.052366+00:00 app[web.1]: npm ERR!
2020-12-12T13:24:42.052464+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2020-12-12T13:24:42.052542+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-12-12T13:24:42.060764+00:00 app[web.1]:
2020-12-12T13:24:42.060946+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-12-12T13:24:42.061060+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-12-12T13_24_42_053Z-debug.log
2020-12-12T13:24:42.120667+00:00 heroku[web.1]: Process exited with status 1
2020-12-12T13:24:42.172343+00:00 heroku[web.1]: State changed from starting to crashed
2020-12-12T13:25:03.810804+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-shop-product.herokuapp.com request_id=3d8f329b-0ca2-45d3-9e92-1a64a92f01b4 fwd="178.121.191.80" dyno= connect= service= status=503 bytes= protocol=https
2020-12-12T13:25:04.536389+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=app-shop-product.herokuapp.com request_id=67dc0dfa-52a6-496d-8c10-8c8f55114482 fwd="178.121.191.80" dyno= connect= service= status=503 bytes= protocol=https
2020-12-12T13:26:38.698873+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-shop-product.herokuapp.com request_id=1fb20423-bc68-4bfd-94ba-57207eeb2f42 fwd="178.121.191.80" dyno= connect= service= status=503 bytes= protocol=https
2020-12-12T13:26:39.299103+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=app-shop-product.herokuapp.com request_id=73c1b6bb-794b-4ae2-998b-e94b3a5b73d5 fwd="178.121.191.80" dyno= connect= service= status=503 bytes= protocol=https